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

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

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

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

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

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

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

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

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