10493 - Shoemaker's Problem   

Description

Shoemaker has N jobs (orders from customers) which he must make. Shoemaker can work on only
one job in each day. For each i-th job, it is known the integer Ti (1<=Ti<=1000), the time in days it
takes the shoemaker to fi nish the job. For each day of delay before starting to work for the i-th job,
shoemaker must pay a fi ne of Si (1<=Si<=10000) cents. Your task is to help the shoemaker, writing a
programm to fi nd the sequence of jobs with minimal total fine.

Input

The input begins with a single positive integer on a line by itself indicating the number
of the cases following, each of them as described below. This line is followed by a blank
line, and there is also a blank line between two consecutive inputs.

      First line of input contains an integer N (0<=N<=1000). The next N lines each contain two
numbers: the time and fi ne of each task in order.

Output

For each test case, the output must follow the description below. The outputs of two
consecutive cases will be separated by a blank line.

     You programm should print the sequence of jobs with minimal fi ne. Each job should be represented
by its number in input. All integers should be placed on only one output line and separated by one
space. If multiple solutions are possible, print the first lexicographically.

Sample Input  Download

Sample Output  Download

Tags




Discuss