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

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

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

m = A("m")
f = B("f")
a = C("a")
c = B("c")
e = B("e")
g = C("g")

m.z = g
f.o = c
a.x = g
a.t = e
c.o = e
e.o = f
g.x = a
g.t = e
assert a.t.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
a = C("a")
c = B("c")
e = B("e")
g = C("g")

m.z = g
f.o = c
a.x = g
a.t = e
c.o = e
e.o = f
g.x = a
g.t = e
assert a.t.o.o.o.o.txt == "f"