Generate permutations iteratively, AC