Twenty cards, each carrying one number from 1 to 20, lie in a row in ascending order. Positions are numbered 1 to 20 from the left.
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Card | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Given a segment [a,b] with 1≤a≤b≤20, put the cards from position a to position b back in the reverse of their current order.
Suppose the segment [5,10] is given in the starting state. Cards 5, 6, 7, 8, 9, 10 at positions 5 to 10 become 10, 9, 8, 7, 6, 5, and the whole row looks like this.
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Card | 1 | 2 | 3 | 4 | 10 | 9 | 8 | 7 | 6 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
If the segment [9,13] is given next, cards 6, 5, 11, 12, 13 at positions 9 to 13 become 13, 12, 11, 5, 6, and the whole row looks like this.
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Card | 1 | 2 | 3 | 4 | 10 | 9 | 8 | 7 | 13 | 12 | 11 | 5 | 6 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Ten segments are given for the twenty cards that start in ascending order. Apply the reversals one after another in the given order and report the final arrangement.
Ten lines each hold one segment. Line i holds the start position ai and the end position bi of the i-th segment, separated by a space, with 1≤ai≤bi≤20.
Print the arrangement after all ten segments have been applied in the given order, on one line. Write the card numbers at positions 1 to 20, separated by single spaces.