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

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

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

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

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

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

k.u = n
k.q = n
l.t = k
n.t = k
assert l.t.q.t.txt == "k"