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

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

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

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

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

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

j.u = l
n.q = j
l.q = j
assert l.q.u.q.txt == "j"