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

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

g = A("g")
k = B("k")
m = B("m")
b = A("b")
i = B("i")
h = B("h")
f = B("f")
l = A("l")
n = B("n")

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

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

g = A("g")
k = B("k")
m = B("m")
b = A("b")
i = B("i")
h = B("h")
f = B("f")
l = A("l")
n = B("n")

g.q = b
k.t = m
k.u = f
m.t = i
m.u = n
b.q = l
i.t = m
i.u = m
h.t = m
h.u = i
f.t = n
f.u = m
l.q = b
n.t = f
n.u = h
assert i.t.t.t.t.u.t.txt == "i"