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

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

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

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

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

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

i.q = l
i.s = g
l.u = n
n.q = g
n.s = l
g.u = n
assert i.q.u.s.u.txt == "n"