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

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

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

k = A("k")
d = B("d")
j = C("j")
c = A("c")
a = C("a")
f = A("f")
l = B("l")

k.t = a
k.z = a
k.r = j
d.y = l
d.q = l
d.r = j
j.r = a
j.z = d
c.t = a
c.r = a
c.z = j
a.r = j
a.z = d
f.t = a
f.z = j
f.r = j
l.y = d
l.q = d
l.r = j
assert l.q.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: C = None
        self.r: C = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
j = C("j")
c = A("c")
a = C("a")
f = A("f")
l = B("l")

k.t = a
k.z = a
k.r = j
d.y = l
d.q = l
d.r = j
j.r = a
j.z = d
c.t = a
c.r = a
c.z = j
a.r = j
a.z = d
f.t = a
f.z = j
f.r = j
l.y = d
l.q = d
l.r = j
assert l.q.r.r.r.txt == "j"