QUE1  Queue (Rookie)
There are N people standing in a Queue. You are given the height of each person and the number of people who are taller and standing ahead of him. You have to find the position of each person.
Input
First line conatins a single integer T, the number of test cases. It is followed by T test cases each of which contains 3 lines. First line of each test case contains a single integer N. Second line contains N integers representing the heights of these N people. Third line also contains N integers denoting the number of taller people standing ahead of him.
Output
Output one line for each test case which contains the heights of the N people in the order in which they are standing.
Constraints
0 < T <= 100
0 < N <= 1000
Example
Input: 1 5 33 11 22 44 55 0 2 1 1 0 Output: 33 22 11 55 44
Harder Version : Queue (Pro)
hide comments
ankkt16:
20190217 12:10:37
ac at once :)


dung199551:
20190121 19:19:19
8 3 2 8 7 4 9 5


abhu:
20181108 07:56:01
Good reading material : http://mathonline.wikidot.com/generatingpermutationswithinversionsequences Last edit: 20181108 08:04:24 

codiesam_007:
20180604 23:56:03
My 150th !!


karthik1997:
20180108 08:15:24
Man , struggled too hard to get an NlogN solution . Really good problem :) Last edit: 20180108 08:15:44 

sandeep_123:
20171215 11:46:07
A very good problem!!, simple iterative solution. Last edit: 20171215 11:59:34 

leduchuybk:
20170914 19:58:37
I dont know if anyone gets the wrong mistakes like me but warning.


sandip_coder:
20170211 19:01:50
nice problem...


shaan001:
20160919 14:09:33
platwnas: 20160620 15:57:02


platwnas:
20160620 15:57:02
Cant understand the test case. Which way are the people looking ? And provide more test cases.

Added by:  Shikhar 
Date:  20130916 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 PYTHON PYTHON3 PY_NBC 
Resource:  Directi Interview 