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

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

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

d = A("d")
m = B("m")
e = C("e")
h = A("h")

d.o = e
d.z = m
m.z = d
m.y = h
e.t = d
h.o = e
h.z = m
assert h.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
e = C("e")
h = A("h")

d.o = e
d.z = m
m.z = d
m.y = h
e.t = d
h.o = e
h.z = m
assert h.o.t.o.txt == "e"