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

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

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

c = A("c")
i = B("i")
b = C("b")

c.p = i
c.w = i
i.p = b
b.u = c
assert c.p.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: B = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
b = C("b")

c.p = i
c.w = i
i.p = b
b.u = c
assert c.p.p.u.txt == "c"