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

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

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

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

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

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

m.t = i
m.z = i
f.z = a
b.t = a
b.z = i
l.t = f
l.z = a
k.t = a
k.z = f
h.t = f
h.z = i
a.z = f
i.z = a
n.t = a
n.z = a
assert k.t.z.z.z.z.txt == "a"