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

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

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

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

n.w = e
e.p = c
c.w = n
c.v = e
assert c.w.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

n.w = e
e.p = c
c.w = n
c.v = e
assert c.w.w.p.txt == "c"