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

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

e = A("e")
i = B("i")
a = B("a")
j = A("j")
m = A("m")

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

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

e = A("e")
i = B("i")
a = B("a")
j = A("j")
m = A("m")

e.z = a
i.s = e
i.x = a
a.s = e
a.x = i
j.z = a
m.z = a
assert m.z.x.x.s.z.txt == "a"