시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

문제

Somewhere in an animal kingdom far from here there is a large forest. Inside the forest live a large number of frogs. Every year the frogs gather along the big central road in the forest to show the other animals their unique ability during the Big Animal Prowess Conference (BAPC).

These frogs are experts in forming towers by climbing on top of each other. They are, however, not experts in gathering orderly on the road, so the frogs have arrived on different positions along the central road. The frogs are also notorious show offs: their every jump is as far as they can and always a prime distance. Not every frog is as strong as the others, so jumping distances may vary. Naturally, the frogs only jump to increase their position, never the other way!

The frog king wants to invite all visitors of the BAPC to marvel at the most spectacular frog tower. Multiple frog towers can be created, but the king wants to show the largest tower at the smallest possible position. He doesn’t want anyone to miss the action because they were at the wrong spot! Can you help the frog king determine the position and size of the tower?

입력

  • On the first line one integer n, the number of frogs gathering on the central road, with 1 ≤ n ≤ 40.
  • Then follow n lines with integers xi and di, the initial position and prime jumping distance of the i th frog. Here 0 ≤ xi ≤ 260 and 2 ≤ di ≤ 108  It is given that the product of all unique jumping distances is less than 109.

출력

Output a single line with two integers indicating:

  • the smallest position of the highest frog tower,
  • the size of the highest frog tower.

Separate these integers by a space.

예제 입력 1

3
0 2
1 2
3 3

예제 출력 1

3 2

예제 입력 2

5
0 2
1 3
3 3
7 5
9 5

예제 출력 2

12 3

예제 입력 3

2
9972 9973
9966 9967

예제 출력 3

99400890 2

힌트