Shoes maker's problem


Program SHOES.C, SHOES.CPP, SHOES.PAS

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

The Input
First line of input for each case contains an integer N (1<=N<=1000). The next N lines each contain two integers: the time and fine of each task in order. Time is never less than 1. A value N = 0 indicates end of input.

The Output
For each case, your program should print the case number, followed by the sequence of jobs with minimal fine. 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
3
1 5
2 4
3 3
4
3 4
1 1000
2 2
5 5
0

Sample Output
Case #1: 1 2 3
Case #2: 2 1 3 4