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

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

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

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

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

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

k.s = i
k.q = i
l.v = e
l.w = e
e.v = l
e.w = l
i.s = k
i.q = g
g.s = i
g.q = k
assert e.v.v.v.v.txt == "e"