Leaders

Animals in a circle alternately raise a running number by 1 to K; whoever is forced to say M loses, and we find the winner of every start position.

Hard9Game theoryDynamic programmingImplementationMathNo attempts yetTime limit3sMemory limit512 MB

Problem

Goats and sheep have argued for years over the fields they graze. After many fierce fights, the goat leader and the sheep leader met to look for a peaceful solution. After hours of discussion they agreed to play one game for each field, and the winning team grazes that field.

The game works like this. NN animals, each of them a goat or a sheep, stand in a circle. The two leaders fix in advance which position holds a goat and which holds a sheep. Animal ii (1iN11 \le i \le N-1) is followed by animal i+1i+1, and animal NN is followed by animal 11.

The animal that starts the game says an integer between 11 and KK. If the animal before it said jj, the next animal says an integer between j+1j+1 and j+Kj+K. In other words, each animal says a number that is greater than the previous number by at least 11 and at most KK. No animal may say a number greater than MM, and the team of the animal that says MM loses.

Every animal plays optimally for its own team. For each ii (1iN1 \le i \le N), determine which team takes the field when animal ii starts the game.

Input

The first line contains NN, MM and KK, separated by spaces (1N,M,K50001 \le N, M, K \le 5000).

The second line contains NN numbers separated by spaces. The ii-th number is 00 if animal ii is a sheep and 11 if it is a goat.

Output

Print NN numbers separated by spaces on one line. The ii-th number is 00 if the sheep take the field and 11 if the goats take it, when animal ii starts the game.

Hint

In the first example the sheep starts and wins like this. The sheep says 22, so the goat says 33 or 44, and in both cases the sheep can say 55. The goat then says 66 or 77, and in both cases the sheep can say 88. After that the goat has nothing left to say but 99, so it loses the game and the field.