def invert_map(dic):
    """
    Inverts map. Raises ValueError if map is not invertible.
    """
    inv = {v: k for k, v in dic.items()}
    if len(inv) != len(dic):
        raise ValueError("map not invertible!")
    return inv