Elephant

Time limit3sMemory limit128 MB

Problem

There are N plants floating on a lake represented as a coordinate plane. Each plant is located at a distinct integer coordinate.

Every morning, an elephant exercises by jumping between plants. From a plant at (x1, y1), it may jump only to a plant at (x2, y2) where x2 > x1 and y2 > y1. The elephant may start from any plant.

Given all plant coordinates, find the maximum number of plants the elephant can visit. Also find the number of jump sequences that visit that maximum number of plants. Since this number can be very large, print it modulo 1 000 000 007.

Input

The first line contains the number of plants N. (1 <= N <= 300 000)

Each of the next N lines contains the coordinates xi and yi of one plant. (0 <= xi, yi <= 1 000 000 000)

No two plants have the same coordinate.

Output

On the first line, print the maximum number of plants the elephant can visit.

On the second line, print the number of jump sequences that achieve that maximum, modulo 1 000 000 007.