All Submissions


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 Specification
First line contains a single integer T, the number of test cases. Each test case has 3 lines, first line contains a single integer N. Second line contains N integer which are the heights of N people in the queue. Third line also contains N integers which is the number of people standing ahead of him.

Output Specification
Output one line for each test case which contains the heights of the people in the order in which they are standing in the Queue. All heights should be separated by a single space.

Constraints
1 <= T <= 10
1 <= N <= 1000 (This is the only difference between Rookie and Pro versions of the problem).
1 <= Height <= 10^7
0 <= No of taller people standing ahead < N
All heights are distinct.
Expected Time Complexity : O(N^2)

Sample Input
1
5
33 11 22 44 55
0 2 1 1 0


Sample Output
33 22 11 55 44

Problem Setter : Shikhar Sharad
Problem Tester : Arjun Singh Bhatia
Problem Source : Directi Interview


Languages: Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 1 Second(s)
Score: 25 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0