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

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

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

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

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

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

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

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

h.u = c
c.s = h
c.y = h
d.u = c
assert h.u.s.u.txt == "c"