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

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

e = A("e")
k = B("k")
l = A("l")
g = B("g")
i = A("i")

e.s = i
e.z = g
k.q = g
k.u = i
l.s = i
l.z = g
g.q = k
g.u = l
i.s = e
i.z = g
assert k.u.s.s.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.txt = txt

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

e = A("e")
k = B("k")
l = A("l")
g = B("g")
i = A("i")

e.s = i
e.z = g
k.q = g
k.u = i
l.s = i
l.z = g
g.q = k
g.u = l
i.s = e
i.z = g
assert k.u.s.s.s.z.txt == "g"