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

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

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

n = A("n")
j = B("j")
e = C("e")
f = C("f")

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

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

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

n = A("n")
j = B("j")
e = C("e")
f = C("f")

n.s = f
j.s = f
j.p = n
e.p = f
e.s = j
e.v = n
f.p = e
f.s = j
f.v = n
assert e.v.s.v.s.txt == "f"