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

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

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

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

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

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

f.s = e
f.w = a
m.z = e
h.s = e
h.w = f
j.z = e
n.z = j
e.z = m
a.s = n
a.w = h
b.s = e
b.w = i
i.s = m
i.w = a
l.s = n
l.w = b
assert l.s.z.z.z.z.z.z.z.z.z.txt == "m"