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

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

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

n = A("n")
f = B("f")
a = C("a")
m = B("m")
l = A("l")
e = A("e")

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

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

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

n = A("n")
f = B("f")
a = C("a")
m = B("m")
l = A("l")
e = A("e")

n.p = a
n.v = l
f.x = a
f.s = a
a.v = n
m.x = a
m.s = a
l.p = a
l.v = n
e.p = a
e.v = n
assert e.v.v.p.v.p.v.txt == "n"