companion can be set before the I-th companion on the photograph if his square shape is lower and smaller than the square shape of the I-th companion. Officially, somewhere around one of the accompanying conditions should be satisfied: hj
Correct answer will be upvoted else Multiple Downvoted. Computer science.
The j-th companion can be set before the I-th companion on the photograph if his square shape is lower and smaller than the square shape of the I-th companion. Officially, somewhere around one of the accompanying conditions should be satisfied:
hj<hi and wj<wi (the two companions are standing or both are lying);
wj<hi and hj<wi (one of the companions is standing and the other is lying).
For instance, on the off chance that n=3, h=[3,5,3] and w=[4,4,3]:
the main companion can be set before the second: w1<h2 and h1<w2 (one of the them is standing and the other one is lying);
the third companion can be put before the second: h3<h2 and w3<w2 (the two companions are standing or both are lying).
In different cases, the individual in the closer view will cover the individual behind the scenes.
Help Polycarp for every I find any j, with the end goal that the j-th companion can be situated before the I-th companion (for example somewhere around one of the conditions above is satisfied).
If it's not too much trouble, note that you don't have to find the game plan surprisingly for a gathering photograph. You simply need to find for every companion I some other companion j who can be situated before him. Consider it as you really want to settle n separate free subproblems.
Input
The main line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow.
The main line of each experiment contains one integer n (1≤n≤2⋅105) — the number of companions.
This is trailed by n lines, every one of which contains a depiction of the relating companion. Every companion is depicted by two integers howdy and wi (1≤hi,wi≤109) — tallness and width of the I-th companion, individually.
It is ensured that the amount of n over all experiments doesn't surpass 2⋅105.
Output
For each experiment output n integers on a different line, where the I-th number is the file of a companion that can be put before the I-th. Assuming there is no such companion, output - 1.
In case there are a few replies, output any.
Step by step
Solved in 4 steps with 1 images