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

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

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

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

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

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

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

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

i.w = k
i.p = b
b.u = i
k.v = i
assert b.u.p.u.txt == "i"