def invert_dict(d):
    """Returns a dictionary that maps from values to lists of keys.

    d: dict

    returns: dict
    """
    inv = dict()
    for key in d:
        val = d[key]
        if val not in inv:
            inv[val] = [key]
        else:
            inv[val].append(key)
    return inv
