Perfect Game

Order the levels to minimize the expected total play time when any death restarts the run from the first level.

Medium7GreedySortingProbabilityNo attempts yetTime limit5sMemory limit512 MB

Problem

In a video game you earn an achievement by clearing every level in a row without dying once. You may play the levels in any order you like, and each attempt at a level either clears it or kills you. Each level has its own chance of killing you and its own duration for one attempt.

An attempt takes the same amount of time whether you clear the level or die in it. As soon as you die you start over from the first level of your chosen order.

Find an order of the levels that minimizes the expected time until you earn the achievement.

Input

The first line contains the number of test cases TT. Each of the TT test cases follows on three lines.

The first line of a test case contains the number of levels NN. The second line contains NN space-separated integers LiL_i. LiL_i is the number of seconds one attempt at level ii takes, whether you clear it or die. The third line contains NN space-separated integers PiP_i. PiP_i is the percent chance that one attempt at level ii kills you.

Levels are numbered from 00 to N1N-1.

Limits

  • 1T1001 \le T \le 100
  • 1N10001 \le N \le 1000
  • 1Li1001 \le L_i \le 100
  • 0Pi<1000 \le P_i < 100

Output

For each test case, print one line containing Case #x: followed by NN space-separated integers. Here xx is the test case number, starting from 11.

The jjth integer is the number of the level you attempt jjth. The printed sequence must be a permutation of 00 to N1N-1 whose expected time to earn the achievement is the smallest possible.

If several orders reach that smallest expected time, print the lexicographically least one among them. Of two orders, the lexicographically smaller one has the smaller number at the first position where they differ.