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

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

h = A("h")
b = B("b")
m = A("m")
n = A("n")
g = A("g")
f = B("f")
a = A("a")
e = B("e")
c = A("c")

h.t = e
b.q = e
m.t = e
n.t = e
g.t = b
f.q = b
a.t = f
e.q = b
c.t = e
assert a.t.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

h = A("h")
b = B("b")
m = A("m")
n = A("n")
g = A("g")
f = B("f")
a = A("a")
e = B("e")
c = A("c")

h.t = e
b.q = e
m.t = e
n.t = e
g.t = b
f.q = b
a.t = f
e.q = b
c.t = e
assert a.t.q.q.q.q.q.q.q.q.txt == "e"