Washing Plates#210

Washing Plates

1 second
128 megabytes
Easy (≈1000)

After the birthday party, there were dirty plates stacked on top of each other. Khadija and Zeynab didn't want to leave the plates dirty. They decided among themselves that Khadija would wash the plates and Zeynab would dry the washed plates.

For example, if there are n=5 plates, then they are numbered from to from top to bottom:

Khadija picks up x=3 dirty plates from the top one by one and washes them, placing them on top of the washed plates:

Zeynab takes y=2 washed plates from the top one by one and dries them, placing them on top of the washed and dried plates:

Khadija picks up the last x=2 dirty plates from the top one by one and washes them, placing them on top of the washed plates:

Finally, Zeynab takes y=3 plates from the top of the washed plates one by one and dries them, placing them on top of the washed and dried plates:

At the end, the sequence of the plates from top to bottom will be: 1, 4, 5, 2, 3

Input

The first line provides the natural number indicating the number of dirty plates. In the following lines, the turns of Khadija and Zeynab are given in the following format:

  • 1 x - Khadija washes dirty plates.

  • 2 y - Zeynab dries washed plates.

Output

Output lines, providing the sequence of the plates from top to bottom after they are washed and dried. The example test is explained in the problem statement.

Examples

Example 1

Loading
Loading