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

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

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

d = A("d")
b = B("b")
l = C("l")
h = B("h")

d.z = h
d.o = l
b.u = d
b.y = h
b.z = l
l.s = b
l.x = d
h.u = d
h.y = b
h.z = l
assert h.u.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
l = C("l")
h = B("h")

d.z = h
d.o = l
b.u = d
b.y = h
b.z = l
l.s = b
l.x = d
h.u = d
h.y = b
h.z = l
assert h.u.o.x.txt == "d"