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

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

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

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

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

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

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