The Race

No attempts yetTime limit1sMemory limit128 MB

Problem

During the annual interstellar competition for tuned spaceships, NN spaceships compete. Each spaceship ii is tuned so that it can accelerate in zero time to its maximum speed ViV_i and then cruise at that speed forever. Because of past achievements, each spaceship starts at position XiX_i, i.e. it begins XiX_i kilometers past the starting line.

The race course is infinitely long. Because the spaceships move so fast, the course runs perfectly straight the whole way. On this straight course, spaceships can pass one another very easily, without interfering with each other.

Many spectators have not yet realized that the outcome of the race can be determined in advance. Your task is to show this: report how many times spaceships pass one another, and predict the first 1000010\,000 passings in chronological order.

You may assume that every spaceship starts at a different position. Furthermore, no more than two spaceships are ever at the same position on the course at the same time.

Input

The input consists of several races. The first line of each race contains the number of spaceships NN (0<N2500000 < N \le 250\,000). Each of the next NN lines describes one spaceship: the (i+1)(i+1)-th line contains two integers XiX_i and ViV_i, the starting position and the velocity of the ii-th spaceship (0Xi10000000 \le X_i \le 1\,000\,000, 0<Vi<1000 < V_i < 100). The spaceships are ordered by starting position, i.e. X1<X2<<XNX_1 < X_2 < \cdots < X_N. The starting position is the number of kilometers past the starting line where the spaceship starts, and the velocity is given in kilometers per second.

The input is terminated by a race with 00 spaceships; no output should be produced for that race.

Output

For each race, output the following. The first line contains the number of times spaceships pass one another during the race, taken modulo 10000001\,000\,000.

Each of the following lines represents one passing, in chronological order. If there are more than 1000010\,000 passings, output only the first 1000010\,000; if there are fewer than 1000010\,000, output all of them. Each line consists of two integers ii and jj, meaning that spaceship ii passes spaceship jj. If several passings happen at the same time, sort them by their position on the course: a passing that takes place closer to the starting line is listed first. The time of a passing is the moment when the two spaceships are at the same position.