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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

c = A("c")
m = B("m")
j = C("j")
a = D("a")
l = B("l")
f = B("f")
b = C("b")
e = A("e")
k = B("k")

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

c = A("c")
m = B("m")
j = C("j")
a = D("a")
l = B("l")
f = B("f")
b = C("b")
e = A("e")
k = B("k")

c.q = e
c.z = a
m.r = a
j.t = m
j.q = c
j.r = b
j.p = b
a.u = e
l.r = a
f.r = a
b.t = k
b.q = c
b.r = j
b.p = j
e.q = c
e.z = a
k.r = a
assert c.z.u.z.u.q.q.q.z.u.txt == "e"