Cutting a Rectangle

No attempts yetTime limit1sMemory limit1024 MB

Problem

Irus had a single rectangle whose sides have integer lengths. He cut the rectangle with one straight line parallel to a side, splitting it into two rectangles, set one of them aside (a rectangle that has been set aside is never cut again), and kept cutting the other one in the same way. He repeated this until he had KK rectangles in total; every rectangle produced this way has integer side lengths.

When Irus sorted the KK resulting rectangles by the length of their longer edge, he found that these longer-edge lengths were all distinct (the shorter-edge lengths, however, may coincide).

Irus has forgotten the size of the original rectangle. Help him by finding every possible size of the initial rectangle.

Input

The first line contains the number of rectangles KK. Each of the next KK lines contains two natural numbers aia_i and bib_i, the side lengths of the ii-th rectangle. They are given so that aibia_i \ge b_i, and they are ordered so that a1<a2<<aKa_1 < a_2 < \cdots < a_K.

Output

On the first line, print PP, the number of possible sizes of the initial rectangle.

On each of the next PP lines, print the length of the shorter edge of one possible initial rectangle, in increasing order (a rectangle of a given size is counted only once, even if there are several ways to cut it into the KK given rectangles).

Constraints

  • 2K1000002 \le K \le 100000
  • 1biai<ai+150000001 \le b_i \le a_i < a_{i+1} \le 5000000 for all ii