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

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

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

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

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

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

h.z = d
m.t = b
f.z = d
k.t = b
l.z = d
b.t = n
g.z = f
d.z = f
n.t = b
assert m.t.t.t.t.t.t.t.t.t.txt == "b"