Codeforces Round 149 (Div. 2)
B
Big Segment
Codeforces
1100
原题
← AC →
翻译中…

A coordinate line has $*n*$ segments, the $*i*$-th segment starts at the position $*l*_{*i*}$ and ends at the position $*r*_{*i*}$. We will denote such a segment as $[*l*_{*i*}, *r*_{*i*}]$.

翻译中…

You have suggested that one of the defined segments covers all others. In other words, there is such segment in the given set, which contains all other ones. Now you want to test your assumption. Find in the given set the segment which covers all other segments, and print its number. If such a segment doesn't exist, print -1.

翻译中…

Formally we will assume that segment $[*a*, *b*]$ covers segment $[*c*, *d*]$, if they meet this condition $*a* ≤ *c* ≤ *d* ≤ *b*$.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — the number of segments. Next $*n*$ lines contain the descriptions of the segments. The $*i*$-th line contains two space-separated integers $*l*_{*i*}, *r*_{*i*}$ ($1 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ 10^{9}$) — the borders of the $*i*$-th segment.

翻译中…

It is guaranteed that no two segments coincide.

翻译中…

Output

翻译中…

Print a single integer — the number of the segment that covers all other segments in the set. If there's no solution, print -1.

翻译中…

The segments are numbered starting from $1$ in the order in which they appear in the input.

翻译中…

样例

Input #1
3
1 1
2 2
3 3
Output #1
-1
InputCopy OutputCopy
Input #2
6
1 5
2 3
1 10
7 10
7 7
10 10
Output #2
3
InputCopy OutputCopy
题目信息
题号
242B
时间限制
2 s
内存限制
256 MB
标签
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。