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

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

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

b = A("b")
e = B("e")
a = C("a")
n = A("n")

b.p = n
b.w = a
e.r = n
a.v = e
n.p = b
n.w = a
assert a.v.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: C = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
a = C("a")
n = A("n")

b.p = n
b.w = a
e.r = n
a.v = e
n.p = b
n.w = a
assert a.v.r.p.w.txt == "a"