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.w: A = None
        self.p: C = None
        self.txt = txt

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

c = A("c")
n = B("n")
e = C("e")

c.z = e
c.w = n
n.t = c
n.w = c
n.p = e
e.z = c
assert n.t.z.z.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.w: A = None
        self.p: C = None
        self.txt = txt

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

c = A("c")
n = B("n")
e = C("e")

c.z = e
c.w = n
n.t = c
n.w = c
n.p = e
e.z = c
assert n.t.z.z.txt == "c"