시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 128 MB 82 27 13 28.261%

문제

N개의 식물이 표면에 떠 있는 호수에 코끼리 한 마리가 살고 있다. 이 호수는 각각의 식물들이 정수 좌표에 있는 좌표평면으로 나타낼 수 있다.

매일 아침마다 이 코끼리는 식물들 위를 신나게 뛰어다니며 아침 운동을 한다. 왜 그런지는 모르겠지만 이 코끼리는 항상 현재 식물보다 x, y좌표가 둘 다 큰 식물로만 뛸 수 있다. 다시 말해서, (x1, y1)에 있는 식물로부터 x2 > x1이고 y2 > y1일때만 코끼리는 (x2, y2)로 뛸 수 있다. 이 코끼리는 호수 위의 아무 식물에서나 운동을 시작할 수 있다.

모든 식물의 좌표가 주어졌을때, 코끼리가 최대로 뛸 수 있는 식물의 개수를 계산하시오. 그리고 그렇게 뛸 수 있는 방법의 수를 계산하시오. 이때 이 방법의 수가 너무 클 수 있기 때문에 1 000 000 007로 나눈 나머지를 출력하시오.

입력

첫 번째 줄에는 식물의 수 N(1 ≤ N ≤ 300 000)이 들어온다.

이후 N개의 줄에는 각각의 식물의 좌표 xi, yi(0 ≤ xi, yi ≤ 1 000 000 000)가 들어온다. (단, 두 식물이 같은 좌표에 있는 경우는 없다.)

출력

첫 번째 줄에는 코끼리가 최대로 뛸 수 있는 식물의 개수를 출력하시오.

두 번째 줄에는 그렇게 뛸 수 있는 방법의 수를 1 000 000 007로 나눈 값을 출력하시오.

예제 입력 1

6
1 3
2 2
3 1
5 3
4 4
3 5

예제 출력 1

2
7
W3sicHJvYmxlbV9pZCI6IjMxMzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNmNTRcdWIwN2NcdWI5YWMiLCJkZXNjcmlwdGlvbiI6IjxwPk5cdWFjMWNcdWM3NTggXHVjMmRkXHViYjNjXHVjNzc0IFx1ZDQ1Y1x1YmE3NFx1YzVkMCBcdWI1YTAgXHVjNzg4XHViMjk0IFx1ZDYzOFx1YzIxOFx1YzVkMCBcdWNmNTR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