n of Amin's friends gathered at his place to celebrate his birthday. They decided to gather in a row to make a toast to his health. Let's number them in this row from 1 to n.
Among these friends, there are those who know each other and those who don't. Amin's friends' middle school (ai) and university (bi) are specified. If two people have different middle schools and different universities, they don't know each other. From a mathematical point of view, Amin's friends with number i and number j don't know each other if the conditions ai=aj and bi=bj are met.
And Amin, even though it's his birthday, still has strange thoughts and questions coming to his mind. "I wonder if there are two friends in the row from number l to number r (including l and r) who don't know each other? 🤔"
Answer the questions that come to Amin's mind.
The first line contains a single integer n (2≤n≤105), and in each of the following n lines, there are two integers ai and bi (1≤ai,bi≤109,1≤i≤n). The next line specifies the number of queries q (1≤q≤105) that Amin came up with. Each of the next q lines specifies queries, namely two integers lj and rj (1≤lj<rj≤n).
For each query, output two integers on a new line: the numbers of any two of Amin's friends who don't know each other in the specified range, and output 0 0 if there are no such two friends. If there are multiple correct answers, any of them can be output.
This problem consists of 4 subtasks. Points for a subtask are awarded only if all the tests associated with that subtask are passed successfully.
(20 points): n,q≤100;
(30 points): n,q≤1000;
(20 points): n,q≤5000;
(30 points): no additional constraints;