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

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

b = A("b")
h = B("h")
i = A("i")
e = A("e")
l = B("l")
j = A("j")
n = A("n")
m = B("m")
f = B("f")

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

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

b = A("b")
h = B("h")
i = A("i")
e = A("e")
l = B("l")
j = A("j")
n = A("n")
m = B("m")
f = B("f")

b.u = n
b.q = n
h.t = m
i.u = j
i.q = b
e.u = b
e.q = i
l.t = m
j.u = n
j.q = n
n.u = b
n.q = j
m.t = l
f.t = h
assert l.t.t.t.t.t.t.t.t.t.txt == "m"