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

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

k = A("k")
e = B("e")
l = B("l")
f = A("f")

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

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

k = A("k")
e = B("e")
l = B("l")
f = A("f")

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