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

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

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

d = A("d")
l = B("l")
b = C("b")

d.t = b
d.x = b
l.o = b
l.r = b
l.p = d
b.p = d
b.u = d
b.r = d
assert b.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
b = C("b")

d.t = b
d.x = b
l.o = b
l.r = b
l.p = d
b.p = d
b.u = d
b.r = d
assert b.u.t.u.txt == "d"