ZOJ Problem Set - 1487
Gali comes to like playing cards recently. Here is an example of his favorite
game: at the beginning, he holds a pile of 13 cards in his hand with the face
values being 7, A, Q, 2, 8, 3, J, 4, 9, 5, K, 6, 10 from the top to the bottom.
Then he takes the top card and placed it under the bottom card. Next he takes
the current top card and puts it on the table. Gali will repeat these two steps
until there is no more card in his hand. By then Gali will find that the face
values of the cards, according to the order they have been placed on the table,
form an increasing sequence: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K.
The input contains several test cases. Each test case consists of two positive integers n and m where 1 <= n, m <= 2000.
For each test case, output the initial sequence of the n cards in a line. Separate two numbers with a single space.
7 1 12 2 8 3 11 4 9 5 13 6 10
Author: CHEN, Gaoli
Source: ZOJ Monthly, February 2003