#USACO2291. 交换交换交换
交换交换交换
Farmer John's cows are standing in a line. The th cow from the left has label for each 1.Farmer John has come up with a new morning exercise routine for the cows. He has given the cows pairs of integers , where . He then tells the cows to repeat the following -step process exactly times:
- For each from to :
- The sequence of cows currently in positions from the left reverse their order.
After the cows have repeated this process exactly times, please output the label of the th cow from the left for each .
SCORING:
- Test case 2 satisfies .
- Test cases 3-5 satisfy .
- Test cases 6-10 satisfy no additional constraints.
INPUT FORMAT (file swap.in):
The first line contains , and . For each , line line contains and , both integers in the range , where .
OUTPUT FORMAT (file swap.out):
On the th line of output, print the th element of the array after the instruction string has been executed times.
SAMPLE INPUT:
7 2 2
2 5
3 7
SAMPLE OUTPUT:
1
2
4
3
5
7
6
Initially, the order of the cows is[1,2,3,4,5,6,7] from left to right. After the first step of the process, the order is [1,5,4,3,2,6,7]. After the second step of the process, the order is [1,5,7,6,2,3,4]. Repeating both steps a second time yields the output of the sample.