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.txt = txt

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

k.z = m
m.s = k
l.s = g
b.s = k
g.z = l
i.z = m
assert i.z.s.z.s.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.txt = txt

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

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