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

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

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

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

h.u = d
c.t = d
n.u = f
n.z = j
n.q = j
k.t = d
d.u = h
j.t = d
m.t = d
b.u = m
b.z = m
b.q = k
f.t = h
assert n.u.t.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.t: A = None
        self.txt = txt

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

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

h.u = d
c.t = d
n.u = f
n.z = j
n.q = j
k.t = d
d.u = h
j.t = d
m.t = d
b.u = m
b.z = m
b.q = k
f.t = h
assert n.u.t.u.u.u.u.u.txt == "d"