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

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

e = A("e")
f = B("f")
k = A("k")
l = B("l")
d = A("d")
g = A("g")
n = A("n")
a = B("a")
b = B("b")
i = B("i")

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

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

e = A("e")
f = B("f")
k = A("k")
l = B("l")
d = A("d")
g = A("g")
n = A("n")
a = B("a")
b = B("b")
i = B("i")

e.t = b
f.t = b
f.z = n
k.t = a
l.t = b
l.z = n
d.t = l
g.t = l
n.t = f
a.t = l
a.z = n
b.t = f
b.z = e
i.t = f
i.z = n
assert k.t.t.t.z.t.z.t.t.txt == "f"