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

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

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

g = A("g")
e = B("e")
f = C("f")
c = B("c")
d = A("d")

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

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

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

g = A("g")
e = B("e")
f = C("f")
c = B("c")
d = A("d")

g.x = d
g.z = d
e.o = g
e.z = g
e.s = c
f.t = e
c.o = d
c.z = d
c.s = e
d.x = g
d.z = g
assert f.t.z.x.txt == "d"