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

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

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

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

b.p = j
n.o = b
n.v = c
j.p = b
j.s = n
c.p = j
assert j.s.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

b.p = j
n.o = b
n.v = c
j.p = b
j.s = n
c.p = j
assert j.s.v.p.txt == "j"