13513 - Standing in line   

Description

There are N animals standing in line.

The strength of the i-th animal is si and the height of the i-th animal is hi.

The i-th animal is said to be better than the j-th animal if (si > sj) or (si = sj and hi > hj).

For each i = 1, 2, ..., N, find the largest j such that j < i and the j-th animal is better than the i-th animal.

 

Input

The first line of the input contains an integer T, the number of testcases.

The first line of each testcase contains an integer N, the number of animals.

The second line of each testcase contains N integers, s1, s2, ..., sN, the strength of animals.

The third line of each testcase contains N integers, h1, h2, ..., hN, the height of animals.

 

For test 1 to 3, N <= 103.

For test 4 to 6, N <= 105.

T <= 10, si,  hi <= 109.

 

Output

For each testcase, please print N integers j1, j2, ..., jN seperated by space.

ji represent the largest number such that ji < i and the ji-th animal is better than the i-th animal.

If such ji doesn't exist, print 0 instead.

Remember to print a new line at the end of each line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss