Compute permutations
Apply permutation