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

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

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

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

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

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

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

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

d.z = a
d.y = c
d.o = h
h.w = d
h.v = c
a.u = h
c.w = d
c.v = h
assert h.w.o.w.txt == "d"