Problem J
Paper Pile Pandemonium

It’s nearing the end of a busy semester, and you have piles of homework to finish. Literally. All of your homework was printed on sheets of paper (poor trees), which you laid out on your desk in a series of piles. As you were completing the assignments, you moved sheets of paper from the top of one pile to the top of another pile, and kept a diligent log as you did so to keep track of which assignments were completed.
Suddenly, you realize that some of your assignments are due in only in a few minutes, and you need to scan and turn them in now! Through all the shuffling you unfortunately lost track of where all the assignments are amongst the piles. However, your diligent log should let you determine where the assignments must be now. Can you write a program that can determine where all the assignments are now located?
Input
The first line of input contains two space-separated
integers,
The next line contains a single integer,
Output
You should output
Sample Explanation
In the first sample input, the sheets begin in the
configuration below. The numbers
|
||
|
|
|
|
|
|
|
|
|
There are three movements. The first movement takes two
sheets from the top of pile
|
||
|
|
|
|
|
|
|
|
|
The second movement takes a single sheet from the top of
pile
|
||
|
|
|
|
|
|
|
|
|
The third and final movement takes the sheet from pile
|
||
|
||
|
|
|
|
|
|
|
|
|
Sample Input 1 | Sample Output 1 |
---|---|
6 3 3 1 2 3 2 4 5 1 6 3 1 3 2 2 1 1 2 3 1 |
1 5 6 2 3 4 |
Sample Input 2 | Sample Output 2 |
---|---|
20 5 6 6 19 1 20 13 3 2 7 4 3 15 17 11 7 16 18 10 2 12 5 9 2 8 14 10 1 2 5 2 5 3 4 2 2 2 5 5 4 3 1 5 4 9 3 5 3 1 3 1 4 1 6 5 2 3 |
3 4 19 1 5 9 7 17 11 12 15 6 16 18 10 2 14 20 13 8 |