시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB1000.000%

문제

Irus had a rectangle. Irus cut the rectangle and obtained two rectangles. He then put one aside and cut the other one, and continued cutting the same way (never cutting rectangles that were put aside) until he had K rectangles. The edges of all the rectangles have integer lengths.

After he sorted the rectangles by the lengths of their longer edges, Irus realized that these lengths are all distinct (however the lengths of the shorter edges need not be distinct).

Irus forgot the dimensions of the initial rectangle. Help Irus remember them.

입력

The first line contains the number of rectangles K. The remaining K lines contain two natural numbers each, ai and bi, which are the edge lengths of the i-th rectangle, and these numbers are ordered so that ai ≥ bi, and a1 < · · · < aK.

출력

In the first line, output P – the total number of possible dimensions of the initial rectangle.

In the next P lines, output the lengths of the shorter edges of all possible initial rectangles, from smallest to largest (note that we count a rectangle of certain dimensions at most once, even if there are several ways to cut it into the K given rectangles).

제한

  • 2 ≤ K ≤ 100 000
  • 1 ≤ bi ≤ ai < ai+1 ≤ 5 000 000 for all values of i

서브태스크

번호배점제한
125

K ≤ 10

220

bi = 1

355

No additional contraints

예제 입력 1

3
2 1
3 2
4 2

예제 출력 1

2
2
4

The initial rectangles could have been cut in the following ways:

채점 및 기타 정보

  • 예제는 채점하지 않는다.