K-nim
The Code Must Be Respected!
I. Ilf, E. Petrov
Ostap enjoys playing games with his friends, but he often gets in trouble for secretly taking stones from multiple piles at once. Tired of this, he invented his own game where players can take stones from one to K piles simultaneously. The number of piles used can vary from 1 to K, and players can take any number of stones from each pile, even if the amounts differ.
"Now my friends won't accuse me of cheating when I introduce them to this new game! Yes, that's it! I'll call it K-nim" Ostap thought. "But I don't know the rules well enough to play optimally! I need to write a program to suggest the best move... But I can't program either... I'll have to promise half of my future winnings to whoever can write it for me."
Input
The first line of input contains two natural numbers, N and K (N, K ≤ 10^5), representing the number of piles and the maximum number of piles from which stones can be taken in one move, respectively. The second line contains N natural numbers, each up to 10^9, indicating the sizes of the piles.
Output
If Ostap has a winning move, output the number of piles he should take stones from on the first line. On the second line, display the states of all piles after Ostap's move, in the order they were given, with numbers separated by spaces. If Ostap cannot make a winning move, output the single number 0.