def multi_dict(input_pairs):
    """
    Similar to casting pairs to a dictionary, except that repeated pairs
    are allowed. To show the difference:

        >>> dict( [('a', 1), ('b', 2), ('a', 3)] )
        {'a': 3, 'b': 2}

        >>> multi_dict( [('a', 1), ('b', 2), ('a', 3)] )
        {'a': [1, 3], 'b': [2]}

    :param input_pairs:
        A list of (key, value) pairs.
    
    :return:
        A dictionary mapping keys to lists of values.
    """
    output_dict = {}

    for key, value in input_pairs:
        existing_values = output_dict.get(key, [])
        existing_values.append(value)
        output_dict[key] = existing_values

    return output_dict