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

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

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

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

n.p = c
e.s = n
e.r = n
e.y = c
c.v = e
assert n.p.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

n.p = c
e.s = n
e.r = n
e.y = c
c.v = e
assert n.p.v.r.txt == "n"