Generate permutations and test.