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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

 

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY