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

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

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

n = A("n")
c = B("c")
a = C("a")
l = B("l")
e = C("e")
i = A("i")
h = B("h")
f = A("f")
g = A("g")
m = B("m")

n.p = f
c.r = e
c.u = g
c.s = f
a.v = e
a.r = h
l.r = a
l.u = i
l.s = f
e.v = a
e.r = c
i.p = f
h.r = e
h.u = f
h.s = g
f.p = i
g.p = n
m.r = e
m.u = f
m.s = i
assert n.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
a = C("a")
l = B("l")
e = C("e")
i = A("i")
h = B("h")
f = A("f")
g = A("g")
m = B("m")

n.p = f
c.r = e
c.u = g
c.s = f
a.v = e
a.r = h
l.r = a
l.u = i
l.s = f
e.v = a
e.r = c
i.p = f
h.r = e
h.u = f
h.s = g
f.p = i
g.p = n
m.r = e
m.u = f
m.s = i
assert n.p.p.p.p.p.txt == "f"