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

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

e = A("e")
c = B("c")
i = B("i")
b = B("b")
a = A("a")
m = B("m")
n = B("n")

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

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

e = A("e")
c = B("c")
i = B("i")
b = B("b")
a = A("a")
m = B("m")
n = B("n")

e.w = c
c.z = b
i.z = n
b.z = m
a.w = i
m.z = n
n.z = i
assert b.z.z.z.z.z.z.z.txt == "i"