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

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

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

a = A("a")
f = B("f")
i = C("i")
k = B("k")
m = B("m")
c = A("c")
g = A("g")
j = C("j")
d = C("d")

a.t = m
a.z = f
a.o = c
f.o = k
f.r = i
i.r = m
k.o = m
k.r = i
m.o = k
m.r = j
c.t = f
c.z = k
c.o = a
g.t = m
g.z = k
g.o = a
j.r = m
d.r = m
assert a.t.o.o.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.o: A = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
i = C("i")
k = B("k")
m = B("m")
c = A("c")
g = A("g")
j = C("j")
d = C("d")

a.t = m
a.z = f
a.o = c
f.o = k
f.r = i
i.r = m
k.o = m
k.r = i
m.o = k
m.r = j
c.t = f
c.z = k
c.o = a
g.t = m
g.z = k
g.o = a
j.r = m
d.r = m
assert a.t.o.o.o.r.txt == "i"