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

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

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

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

n.u = f
l.q = k
c.u = j
h.q = c
j.q = m
b.u = n
a.u = j
m.u = l
f.u = n
k.u = h
assert l.q.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

n.u = f
l.q = k
c.u = j
h.q = c
j.q = m
b.u = n
a.u = j
m.u = l
f.u = n
k.u = h
assert l.q.u.q.u.q.txt == "m"