Solution to the without repetitions problem.