Balloon Warehouse

Simulate repeated insertions into an infinite balloon line, then report the colors at positions l to r-1 after all instructions.

Hard8TreeDFSRecursionImplementationNo attempts yetTime limit7sMemory limit512 MB

Problem

Darcy manages a balloon warehouse with an unlimited supply of balloons. At the start of the day the warehouse holds one infinitely long line of white balloons. Every colour is written as an integer and 0 means white, so the line begins as 0 0 0 ....

A balloon is identified by its position in the line, counted from the front of the line starting at 0.

During the day Darcy receives nn deliveries. The ii-th delivery brings an unlimited number of balloons of colour yy together with the instruction (x,y)(x, y). If the line holds at least one balloon of colour xx, Darcy inserts exactly one balloon of colour yy immediately after every balloon of colour xx that is in the line at that moment. If the line holds no balloon of colour xx, he sends the delivery back and the line stays as it is.

After the last delivery the supplier asks one question: which colours sit at the positions from ll (inclusive) to rr (exclusive)? Answer that question.

Take a day with the four deliveries (0,1)(0, 1), (1,3)(1, 3), (0,1)(0, 1), (1,2)(1, 2), where 1 is blue, 2 is red and 3 is green. The line changes like this.

start            0 0 0 0 0 0 ...
after (0, 1)     0 1 0 1 0 1 ...
after (1, 3)     0 1 3 0 1 3 ...
after (0, 1)     0 1 1 3 0 1 1 3 ...
after (1, 2)     0 1 2 1 2 3 0 1 2 1 2 3 ...

Input

The first line contains three integers nn, ll and rr. nn is the number of deliveries (1n2000001 \le n \le 200000), and ll and rr mark the range of positions to report (0l<r1060 \le l < r \le 10^6, rl100000r - l \le 100000).

Each of the next nn lines contains two distinct integers xx and yy (0x<2000000 \le x < 200000, 0y<2000000 \le y < 200000), the instruction of one delivery. The deliveries are given in the order they arrive.

Output

Print the colours of the balloons at the positions from ll (inclusive) to rr (exclusive). Print all rlr - l numbers on one line, in order, separated by single spaces.