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

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

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

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

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

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

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

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

j.v = n
j.y = n
j.p = c
n.x = c
c.y = n
c.r = n
assert n.x.r.x.txt == "c"