A coordinate line has *n* segments, the *i*-th segment starts at the position *l*<sub class="lower-index">*i*</sub> and ends at the position *r*<sub class="lower-index">*i*</sub>. We will denote such a segment as [*l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>].

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*.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the number of segments. Next *n* lines contain the descriptions of the segments. The *i*-th line contains two space-separated integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) — the borders of the *i*-th segment.

It is guaranteed that no two segments coincide.
import math
min_start,max_end,segments = math.inf, -math.inf, {}
for i in range(int(input())):
    start,end = map(int,input().split(" "))
    segments[(start,end)] = i + 1
    min_start = min(min_start,start)
    max_end = max(max_end,end)
if (min_start,max_end) in segments:
    print(segments[min_start,max_end])
else: print(-1)


''' 
O(n)

We need to find segment which consists every single other one.

The solution for this problem is to get the earliest start (beginning)
and the latest end among segments, and check whether this segments from these cords exists,
because if we want to cover all other segments this segment should start 
earlier or in the same place as the second earliest (or be first itself) and end in the place 
at least as late as the latest second interval.


We need to remember that it needs to be the 'first beginnning' and the 'last end'
since otherwise we are not able to cover all segments.

'''
