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

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

j = A("j")
m = B("m")
i = A("i")
k = A("k")
l = A("l")
n = A("n")
b = A("b")

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

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

j = A("j")
m = B("m")
i = A("i")
k = A("k")
l = A("l")
n = A("n")
b = A("b")

j.s = m
j.u = m
m.q = j
i.s = m
i.u = m
k.s = m
k.u = m
l.s = m
l.u = m
n.s = m
n.u = m
b.s = m
b.u = m
assert b.u.q.u.q.u.txt == "m"