def W(ws):
    """
    c [w1 w2 ... wn]
    cfirst clast w
    """
    widths = {}
    while ws:
        t = ws.pop()
        if isinstance(t, list):
            c = ws.pop()
            for i, w in enumerate(t):
                widths[c + i] = w
        else:
            c2 = ws.pop()
            c1 = ws.pop()
            for c in range(c1, c2 + 1):
                widths[c] = t
    return widths
