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

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

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

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

d.z = i
d.w = b
b.t = d
i.x = d
i.s = d
i.p = d
assert b.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: B = None
        self.txt = txt

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

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

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

d.z = i
d.w = b
b.t = d
i.x = d
i.s = d
i.p = d
assert b.t.w.t.txt == "d"