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

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

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

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

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

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

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

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

c.t = l
b.r = l
d.x = c
d.z = j
a.r = l
l.t = c
j.x = l
j.z = f
m.r = c
f.x = l
f.z = d
assert d.x.t.t.t.txt == "l"