


If the code name does not match any interval then print -1 for that code name.
The first line of input contains an integer ‘T,’ denoting the number of test cases. The test cases follow:
The first line of each test case contains an integer ‘N’ denoting the number of super heroes.
The second line of each test case contains 2 * N space-separated integers of there presented in a 2 D array, say ‘intervals’ denoting the interval range for each superhero.
The third line of each test case contains an integer ‘X’ denoting the number of candidates.
The fourth and the last line of each test case contains X single space separated integers represented in an array, say ‘codeNames’ denoting the code names for ‘X’ candidates.
Output contains ‘N’ single space separated integers denoting the smallest size of interval in which each candidate will reside.
You don’t need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 5 *10 ^ 2
1 <= X <= 5 * 10 ^ 2
Intervals[i].length = 2
1 <= lefti <= righti <= 5 * 10 ^ 2
1 <= codeNames[j] <= 5 * 10 ^ 2
Time Limit: 1 sec.
The idea is to sort the intervals according to the size of the intervals. Then iterate over the sorted intervals. For each interval, find the code name that lies within the interval.
The steps are as follows: