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

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

b = A("b")
c = B("c")
n = A("n")
i = B("i")
a = B("a")
e = A("e")
k = B("k")
m = A("m")
j = B("j")
d = B("d")

b.u = e
c.t = j
c.s = k
n.u = b
i.t = k
i.s = a
a.t = i
a.s = k
e.u = m
k.t = d
k.s = d
m.u = b
j.t = a
j.s = i
d.t = a
d.s = i
assert n.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
n = A("n")
i = B("i")
a = B("a")
e = A("e")
k = B("k")
m = A("m")
j = B("j")
d = B("d")

b.u = e
c.t = j
c.s = k
n.u = b
i.t = k
i.s = a
a.t = i
a.s = k
e.u = m
k.t = d
k.s = d
m.u = b
j.t = a
j.s = i
d.t = a
d.s = i
assert n.u.u.u.txt == "m"