class A:
    def __init__(self, txt: str):
        self.s: A = 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.p: A = None
        self.v: A = None
        self.txt = txt

n = A("n")
m = B("m")
b = C("b")
c = A("c")
j = A("j")
i = C("i")

n.s = c
m.x = b
b.p = j
b.v = j
c.s = n
j.s = n
i.p = n
i.v = n
assert n.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = 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.p: A = None
        self.v: A = None
        self.txt = txt

n = A("n")
m = B("m")
b = C("b")
c = A("c")
j = A("j")
i = C("i")

n.s = c
m.x = b
b.p = j
b.v = j
c.s = n
j.s = n
i.p = n
i.v = n
assert n.s.s.s.s.s.s.txt == "n"