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

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

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

n = A("n")
h = B("h")
m = C("m")
j = A("j")
k = C("k")
l = A("l")
a = C("a")
e = A("e")
b = B("b")

n.u = b
n.p = h
n.s = e
h.p = k
m.u = a
j.u = b
j.p = h
j.s = n
k.u = m
l.u = b
l.p = b
l.s = j
a.u = m
e.u = b
e.p = h
e.s = n
b.p = a
assert k.u.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: B = None
        self.s: A = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
m = C("m")
j = A("j")
k = C("k")
l = A("l")
a = C("a")
e = A("e")
b = B("b")

n.u = b
n.p = h
n.s = e
h.p = k
m.u = a
j.u = b
j.p = h
j.s = n
k.u = m
l.u = b
l.p = b
l.s = j
a.u = m
e.u = b
e.p = h
e.s = n
b.p = a
assert k.u.u.u.u.u.u.u.u.u.txt == "m"