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

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

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

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

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

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

e.x = l
e.v = g
g.q = e
g.x = l
l.x = e
l.v = g
assert e.v.x.x.txt == "e"