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

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

n = A("n")
m = B("m")
c = B("c")
l = B("l")
h = B("h")
b = B("b")

n.s = c
m.s = b
m.u = n
c.s = m
c.u = n
l.s = h
l.u = n
h.s = c
h.u = n
b.s = c
b.u = n
assert m.s.s.s.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

n = A("n")
m = B("m")
c = B("c")
l = B("l")
h = B("h")
b = B("b")

n.s = c
m.s = b
m.u = n
c.s = m
c.u = n
l.s = h
l.u = n
h.s = c
h.u = n
b.s = c
b.u = n
assert m.s.s.s.u.s.u.txt == "n"