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

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

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

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

d.x = c
h.o = c
c.y = h
c.u = h
assert h.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

d.x = c
h.o = c
c.y = h
c.u = h
assert h.o.y.o.txt == "c"