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

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

m = A("m")
e = B("e")
f = A("f")
b = A("b")
i = A("i")

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

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

m = A("m")
e = B("e")
f = A("f")
b = A("b")
i = A("i")

m.z = e
e.o = f
f.z = e
b.z = e
i.z = e
assert i.z.o.z.txt == "e"