class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: A = None
        self.r: B = None
        self.txt = txt

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

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

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

b = A("b")
h = B("h")
k = C("k")
a = D("a")
f = A("f")
l = A("l")
e = A("e")
n = C("n")
c = B("c")

b.x = h
b.r = h
b.z = e
h.t = a
h.p = n
k.p = c
k.u = b
a.q = c
a.r = f
f.x = c
f.r = c
f.z = l
l.x = c
l.z = b
l.r = h
e.x = c
e.z = b
e.r = h
n.p = c
n.u = l
c.t = a
c.p = n
assert l.r.t.q.t.q.t.q.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: A = None
        self.r: B = None
        self.txt = txt

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

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

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

b = A("b")
h = B("h")
k = C("k")
a = D("a")
f = A("f")
l = A("l")
e = A("e")
n = C("n")
c = B("c")

b.x = h
b.r = h
b.z = e
h.t = a
h.p = n
k.p = c
k.u = b
a.q = c
a.r = f
f.x = c
f.r = c
f.z = l
l.x = c
l.z = b
l.r = h
e.x = c
e.z = b
e.r = h
n.p = c
n.u = l
c.t = a
c.p = n
assert l.r.t.q.t.q.t.q.p.u.txt == "l"