def apply_transitions(n, transitions):
    """
    Applies a list of transitions (permutations of two elements)
    on the first *n* integers.

    :param n: number of elements in the permutation
    :param transitions: list of transitions
    :return: permuted ensemble
    """
    ens = list(range(n))
    for a, b in transitions:
        ens[a], ens[b] = ens[b], ens[a]
    return ens