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

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

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

i = A("i")
b = B("b")
e = C("e")
d = A("d")
c = B("c")
f = B("f")
a = A("a")
j = C("j")
m = A("m")

i.x = a
b.x = m
e.t = i
e.z = f
d.x = a
c.x = d
f.x = d
a.x = d
j.t = a
j.z = c
m.x = i
assert d.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
e = C("e")
d = A("d")
c = B("c")
f = B("f")
a = A("a")
j = C("j")
m = A("m")

i.x = a
b.x = m
e.t = i
e.z = f
d.x = a
c.x = d
f.x = d
a.x = d
j.t = a
j.z = c
m.x = i
assert d.x.x.x.x.x.txt == "a"