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

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

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

g = A("g")
d = B("d")
a = C("a")
e = C("e")
f = A("f")
n = B("n")

g.o = d
d.z = a
d.t = g
d.o = n
a.z = e
a.u = e
e.z = a
e.u = a
f.o = n
n.z = a
n.t = g
n.o = d
assert f.o.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
a = C("a")
e = C("e")
f = A("f")
n = B("n")

g.o = d
d.z = a
d.t = g
d.o = n
a.z = e
a.u = e
e.z = a
e.u = a
f.o = n
n.z = a
n.t = g
n.o = d
assert f.o.t.o.t.txt == "g"