Nested Segments

题意翻译

##### 【题目大意】: 你得到了一个序列$a_1,a_2,a_3...a_n$,表示$n$个区间。你的任务是求出一对$(i,j)$,表示区间$j$包含区间$i$(注意是区间$j$包含$i$)。 我们定义区间$[l_2,r_2]$包含区间$[l_1,r_1]$当且仅当$l_1 \geq l_2$且$r_1 \leq r_2$。比如区间$[2,5]$包含区间$[3,5]$,因为$3 \geq 2,5 \leq 5$。再比如区间$[2,5]$不包含区间$[1,4]$,因为$1<2$。 输出一对$(i,j)$表示答案。如果答案不唯一,则输出任意一组解即可(所以本题有`SPJ`)。如果无解,则输出`-1 -1`。 -------------------------------------- ##### 【输入格式】: 第一行一个整数$n(1 \leq n \leq 3 \times 10^5)$,表示区间的个数。 以下$n$行,每行两个数$l,r$,表示一个区间的左右端点。$1 \leq l \leq r \leq 1 \times 10^9$。 ---------------------------------- ##### 【输出格式】: 一行两个数$(i,j)$,表示答案。如果有多解,输出任意一组解即可。如果无解,输出`-1 -1`。 -------------------------------------- 翻译至`HPXXZYY`。

题目描述

You are given a sequence $ a_{1},a_{2},...,a_{n} $ of one-dimensional segments numbered $ 1 $ through $ n $ . Your task is to find two distinct indices $ i $ and $ j $ such that segment $ a_{i} $ lies within segment $ a_{j} $ . Segment $ [l_{1},r_{1}] $ lies within segment $ [l_{2},r_{2}] $ iff $ l_{1}>=l_{2} $ and $ r_{1}<=r_{2} $ . Print indices $ i $ and $ j $ . If there are multiple answers, print any of them. If no answer exists, print -1 -1.

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1<=n<=3·10^{5} $ ) — the number of segments. Each of the next $ n $ lines contains two integers $ l_{i} $ and $ r_{i} $ ( $ 1<=l_{i}<=r_{i}<=10^{9} $ ) — the $ i $ -th segment.

输出格式


Print two distinct indices $ i $ and $ j $ such that segment $ a_{i} $ lies within segment $ a_{j} $ . If there are multiple answers, print any of them. If no answer exists, print -1 -1.

输入输出样例

输入样例 #1

5
1 10
2 9
3 9
2 3
2 9

输出样例 #1

2 1

输入样例 #2

3
1 5
2 6
6 20

输出样例 #2

-1 -1

说明

In the first example the following pairs are considered correct: - $ (2,1),(3,1),(4,1),(5,1) $ — not even touching borders; - $ (3,2),(4,2),(3,5),(4,5) $ — touch one border; - $ (5,2),(2,5) $ — match exactly.