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

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

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

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

c.w = f
f.p = c
f.t = c
f.r = b
b.x = c
b.t = f
assert b.x.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

c.w = f
f.p = c
f.t = c
f.r = b
b.x = c
b.t = f
assert b.x.w.t.txt == "c"