game-of-perfectness-1
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

You're playing a video game, in which you will get an achievement if you complete all of the levels consecutively without dying. You can play the levels in any order, and each time you play a level you'll either complete it or die. Each level has some probability that you'll complete it, and takes some amount of time. In what order should you play the levels so that the expected time it takes you to get the achievement is minimized? Assume that it takes equally long to beat a level or to die in it, and that you will start again from the first level in your ordering as soon as you die.

Note: If you fail to complete a level, you do not personally die—only your character in the game dies. If that were not the case, only a few people would try to earn this achievement.

Input

The first line of the input gives the number of test cases, T. T test cases follow, each of which consists of three lines. The first line of each test case contains a single integer N, the number of levels. The second line contains N space-separated integers Li. Li is the number of seconds level i lasts, which is independent of whether you complete the level or die. The third line contains N space-separated integers Pi. Pi is the percent chance that you will die in any given attempt to complete level i.

Output

For each test case, output one line containing "Case #x: ", where x is the case number (starting from 1), followed by N space-separated integers. The jth integer in the list should be the index of the jth level you should attempt to beat in order to minimize the amount of time you expect to spend earning the achievement.

Indices go from 0 to N-1. If there are multiple orderings that would give the same expected time, output the lexicographically least ordering. Out of two orderings, the lexicographically smaller one is the one with the smaller index at the first location where they differ; out of many orderings, the lexicographically least one is the one that is lexicographically smaller than every other ordering.

Constraints

1 ≤ T ≤ 100.
0 ≤ Pi < 100.

SAMPLE INPUT
1
4
1 1 1 1
50 0 20 20

SAMPLE OUTPUT
Case #1: 0 2 3 1


for tc in range(eval(input())):
	n=eval(input())
	a=list(map(int,input().split()))
	b=list(map(int,input().split()))
	pd=[x1*(x2**2) for (x1,x2) in zip(a,b)]
	i=0
	dic={}
	for j in pd:
		dic[i]=j
		i+=1
	print("Case #"+str(tc+1)+":", end=' ')
	for w in sorted(dic,key=dic.get,reverse=True):
		print(w, end=' ')
	print("")


T = eval(input())
if (T >= 1) and (T <= 100):
	outerOp = []
	for i in range(T):
		val = {}
		op = []
		N = eval(input())

		Li = str(input()).split()
		if len(Li) > N:
			exit()
		for k in range(len(Li)):
			Li[k] = int(Li[k])
			if Li[k] < 0:
				exit()

		Pi = str(input()).split()
		if len(Pi) > N:
			exit()
		for k in range(len(Pi)):
			Pi[k] = int(Pi[k])
			if (Pi[k] < 0) or (Pi[k] > 100):
				exit()

		if len(Li) == len(Pi):
			for k in range(len(Li)):
				if Pi[k] in val:
					temp = val.get(Pi[k])
					temp.append({Li[k]: k})
				else:
					val[Pi[k]] = [{Li[k]: k}]
		else:
			exit()

		sortedKey = sorted(val)
		sortedKey = sorted(sortedKey, reverse=True)
		for k in range(len(sortedKey)):
			temp = val[sortedKey[k]]
			tempKeyList = []
			tempValueList = []
			for j in range(len(temp)):
				tempDict = temp[j]
				tempKey = 0
				tempValue = 0
				for key in tempDict:
					tempKey = key
					tempValue = tempDict[key]
				tempKeyList.append(tempKey)
				tempValueList.append(tempValue)
			for k in range(len(tempKeyList)):
				for j in range(len(tempKeyList)-1-k):
					if tempKeyList[j] < tempKeyList[j+1]:
						tempKeyList[j], tempKeyList[j+1] = tempKeyList[j+1], tempKeyList[j]
						tempValueList[j], tempValueList[j+1] = tempValueList[j+1], tempValueList[j]
			for j in range(len(tempValueList)):
				op.append(tempValueList[j])
			tempStr = ""
		for m in range(len(op)):
			tempStr = tempStr + str(op[m]) + " "
		outerOp.append("Case #" + str(i + 1) + ": " + tempStr[0:len(tempStr)-1])
	for i in range(len(outerOp)):
		print((outerOp[i]))