permutations using arraylists