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

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

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

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

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

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

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