SLON | 프로그래밍의 벗 PivotOJ
PivotOJ

SLON

시간 제한: 3000ms메모리 제한: 128MB출처: CHC 2008 National Competition #2 - SeniorsBOJ 3133

문제

An elephant lives by a lake with N plants on the surface. The lake can be modeled by a coordinate plane, with plants at points with integer coordinates. 

Every morning after waking up, the elephant performs his morning exercise, happily jumping from plant to plant. For reasons best left undiscussed, the elephant can always jump only to another plant with both coordinates larger than the coordinates of the plant it is currently on. In other words, from plant (x1, y1) the elephant can jump to plant (x2, y2) only if x2 > x1 and y2 > y1. The elephant can start his exercise at any plant on the lake. 

Write a program that, given the coordinates of all plants, calculates the length of the longest sequence of plants the elephant can visit. Additionally, calculate the number of different such longest sequences. Because this second number can be large, calculate it modulo 1000000007. 

입력

The first line contains the integer N (1 ≤ N ≤ 300000), the number of plants. 

Each of the following N lines contains the coordinates of one plant, two integers between 0 and 109. No two plants will have the same pair of coordinates. 

출력

On the first line output the length of the longest sequence of plants the elephant can jump on. 

On the second line output the number of such sequences of maximum length, modulo 1000000 007. 

예제

예제 1

입력
4
1 1
4 2
2 3
3 4
출력
3
1

예제 2

입력
6
1 3
2 2
3 1
5 3
4 4
3 5
출력
2
7

예제 3

입력
11
8 6
7 4
5 4
5 1
5 6
6 2
3 2
4 3
4 5
3 5
2 4
출력
4
3
코드를 제출하려면 로그인하세요.