Did you brute force through it by generating all the permutations of the arrays and the elements in each array?