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

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

b = A("b")
c = B("c")
m = B("m")
e = B("e")
i = B("i")
k = B("k")

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

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

b = A("b")
c = B("c")
m = B("m")
e = B("e")
i = B("i")
k = B("k")

b.z = c
c.x = b
m.x = b
e.x = b
i.x = b
k.x = b
assert i.x.z.x.txt == "b"