class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

n = A("n")
h = B("h")
j = C("j")
k = D("k")
i = B("i")
a = A("a")
c = C("c")
d = C("d")

n.x = k
n.q = a
n.y = i
h.u = i
h.s = i
h.p = k
j.x = i
j.y = k
k.p = h
k.y = h
i.u = h
i.s = h
i.p = k
a.x = k
a.q = n
a.y = i
c.x = i
c.y = k
d.x = h
d.y = k
assert d.y.p.p.y.s.s.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

n = A("n")
h = B("h")
j = C("j")
k = D("k")
i = B("i")
a = A("a")
c = C("c")
d = C("d")

n.x = k
n.q = a
n.y = i
h.u = i
h.s = i
h.p = k
j.x = i
j.y = k
k.p = h
k.y = h
i.u = h
i.s = h
i.p = k
a.x = k
a.q = n
a.y = i
c.x = i
c.y = k
d.x = h
d.y = k
assert d.y.p.p.y.s.s.p.y.txt == "h"