Reversing Card Segments

No attempts yetTime limit1sMemory limit256 MB

Problem

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.

Position1234567891011121314151617181920
Card1234567891011121314151617181920

Given a segment [a,b][a, b] with 1ab201 \le a \le b \le 20, put the cards from position aa to position bb back in the reverse of their current order.

Suppose the segment [5,10][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.

Position1234567891011121314151617181920
Card1234109876511121314151617181920

If the segment [9,13][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.

Position1234567891011121314151617181920
Card1234109871312115614151617181920

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.

Input

Ten lines each hold one segment. Line ii holds the start position aia_i and the end position bib_i of the ii-th segment, separated by a space, with 1aibi201 \le a_i \le b_i \le 20.

Output

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.