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

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

a = A("a")
m = B("m")
l = B("l")
h = A("h")
n = B("n")
c = A("c")
i = A("i")
f = A("f")

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

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

a = A("a")
m = B("m")
l = B("l")
h = A("h")
n = B("n")
c = A("c")
i = A("i")
f = A("f")

a.u = l
m.s = i
l.s = i
h.u = m
n.s = h
c.u = m
i.u = n
f.u = n
assert i.u.s.u.s.txt == "i"