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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: B = None
        self.o: A = None
        self.txt = txt

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

h.u = n
d.q = n
d.x = a
d.u = m
l.w = b
l.t = m
l.o = n
n.u = h
b.q = n
b.x = a
b.u = d
f.w = b
f.t = d
f.o = n
j.q = h
j.x = l
j.u = m
m.q = n
m.x = f
m.u = d
a.w = b
a.t = d
a.o = n
assert b.q.u.u.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.q: A = None
        self.x: C = None
        self.u: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: B = None
        self.o: A = None
        self.txt = txt

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

h.u = n
d.q = n
d.x = a
d.u = m
l.w = b
l.t = m
l.o = n
n.u = h
b.q = n
b.x = a
b.u = d
f.w = b
f.t = d
f.o = n
j.q = h
j.x = l
j.u = m
m.q = n
m.x = f
m.u = d
a.w = b
a.t = d
a.o = n
assert b.q.u.u.u.u.u.txt == "h"