from typing import OrderedDict


def group_unique_values(items):
    """group items (pairs) into dict of lists.
    Values in each group stay in the original order and must be unique

    Args:
        items: iterable of key-value pairs

    Returns:
        dict of key -> lists (of unique values)

    Raises:
        ValueError if value in a group is a duplicate
    """

    result_lists = OrderedDict()
    result_sets = OrderedDict()
    for key, val in items:
        if key not in result_lists:
            result_lists[key] = []
            result_sets[key] = set()
        if val in result_sets[key]:
            raise ValueError("Duplicate value: %s" % val)
        result_sets[key].add(val)
        result_lists[key].append(val)
    return result_lists