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

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

e = A("e")
a = B("a")
b = B("b")
i = A("i")
l = A("l")
m = A("m")

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

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

e = A("e")
a = B("a")
b = B("b")
i = A("i")
l = A("l")
m = A("m")

e.x = a
e.z = a
a.x = b
b.x = a
i.x = a
i.z = b
l.x = b
l.z = a
m.x = b
m.z = a
assert m.x.x.x.x.txt == "a"