def build_lug_list(selection, overlaps):
    """Build a lug list given the current selection and overlaps list."""

    remaining = list(selection)

    lug_list = []
    for x, y, n in overlaps:
        lug_list.extend([(x, y)] * n)
        remaining[x] -= n
        remaining[y] -= n

    for n in range(6):
        lug_list.extend([(n, )] * remaining[n])

    return lug_list