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

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

n = A("n")
i = B("i")
m = B("m")
g = A("g")
l = B("l")
b = A("b")

n.s = i
i.z = b
m.z = n
g.s = l
l.z = b
b.s = l
assert n.s.z.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

n = A("n")
i = B("i")
m = B("m")
g = A("g")
l = B("l")
b = A("b")

n.s = i
i.z = b
m.z = n
g.s = l
l.z = b
b.s = l
assert n.s.z.s.z.s.txt == "l"