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

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

l = A("l")
b = B("b")
e = A("e")
j = B("j")

l.v = e
l.q = b
b.v = l
b.t = j
e.v = l
e.q = j
j.v = l
j.t = b
assert l.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
e = A("e")
j = B("j")

l.v = e
l.q = b
b.v = l
b.t = j
e.v = l
e.q = j
j.v = l
j.t = b
assert l.v.v.v.txt == "e"