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

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

a = A("a")
n = B("n")
l = B("l")

a.u = l
a.v = n
n.q = a
l.q = a
assert a.v.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

a = A("a")
n = B("n")
l = B("l")

a.u = l
a.v = n
n.q = a
l.q = a
assert a.v.q.u.txt == "l"