partial permutations solution