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

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

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

d = A("d")
c = B("c")
b = C("b")
a = B("a")
i = B("i")
h = B("h")

d.o = b
d.z = b
c.y = d
b.z = c
b.o = c
a.y = d
i.y = d
h.y = d
assert b.z.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
b = C("b")
a = B("a")
i = B("i")
h = B("h")

d.o = b
d.z = b
c.y = d
b.z = c
b.o = c
a.y = d
i.y = d
h.y = d
assert b.z.y.o.o.txt == "c"