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

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

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

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

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

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

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