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

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

l = A("l")
i = B("i")
b = B("b")
m = B("m")
g = A("g")
f = A("f")
c = B("c")
n = A("n")

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

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

l = A("l")
i = B("i")
b = B("b")
m = B("m")
g = A("g")
f = A("f")
c = B("c")
n = A("n")

l.s = i
l.u = n
i.z = g
b.z = f
m.z = n
g.s = m
g.u = n
f.s = c
f.u = g
c.z = l
n.s = b
n.u = f
assert m.z.s.z.u.u.txt == "n"