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

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

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

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

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

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

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

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

c.t = e
c.r = e
c.z = d
j.p = e
j.s = d
e.z = l
e.y = f
e.q = c
f.p = e
f.s = d
l.p = e
l.s = c
d.t = e
d.r = e
d.z = c
assert l.s.r.q.z.r.txt == "e"