Tofu Game

Simulate the tofu game: each shouted block number selects the next reference, and print which person holds it, stopping at the terminal value.

Medium4SimulationImplementationMathArrayNo attempts yetTime limit2sMemory limit128 MB

Problem

Kyunghwan joined a round of the tofu game with older students, lost track of the rules, and paid for it. To be ready next time, he decided to write a program that follows the game for him.

The tofu game is played by N people sitting in a circle. The seats are numbered 1 to N, and the direction of increasing numbers is the direction around the circle. Seat 1 comes right after seat N. One game is played with M blocks, where M is an odd number greater than 1.

When a round starts, the person acting as the reference gets the integer part of (M/2+1)(M/2+1), that is (M+1)/2(M+1)/2, as a block number. The people seated behind the reference receive the following block numbers in order, up to M, and the people seated in front of the reference receive the preceding block numbers in order, down to 1. The reference of the first round is the host A.

For example, when 5 people sit in a circle, play the 5 block game, and person 2 is the reference, person 2 gets block 3, persons 3 and 4 get blocks 4 and 5, and persons 1 and 5 get blocks 2 and 1.

The reference shouts a block number X with 1XM1 \le X \le M. The person who holds X becomes the reference of the next round, and the block numbers are handed out again around the new reference. When N is smaller than M, one person receives several block numbers, and the person for X is then the one sitting at the seat you reach by counting from the reference as described above.

If the reference shouts their own block number by mistake, the game ends right there. Assume nobody ever shouts out of turn.

Input

The first line has N, M, and A separated by single spaces. N is an integer with M/2<N<100000M/2 < N < 100000, M is an odd number greater than 1 and smaller than 10000, and A is an integer with 1AN1 \le A \le N.

From the second line on, each line holds one block number shouted by the current reference. Every block number is an integer between 1 and M. The end of the input is the integer part of (M/2+1)(M/2+1), and there are at most 10000 lines from the second line on.

Output

Starting from the first reference, print the number of the person who holds each shouted block number, one per line, in input order. When the block number that marks the end of the input appears, print 0 and stop.