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.


-----Input-----

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.


-----Output-----

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.


-----Examples-----
Input
5
1 10
2 9
3 9
2 3
2 9

Output
2 1

Input
3
1 5
2 6
6 20

Output
-1 -1



-----Note-----

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.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = []
for i in range(1, n + 1):
    l, r = list(map(int, input().split()))
    a.append([l, -r, i])
a.sort()
hh = a[0][1]
wahh = max(-1, a[0][2])
for i in range(1, n):
    if a[i][1] >= hh:
        print(a[i][2], wahh)
        return
    else:
        hh = a[i][1]
        wahh = a[i][2]
print(-1, -1)


n = int(input())
L = []
for i in range(n):
    L.append(list(map(int, input().split()))+[i+1])
#print(L)
L.sort(key=lambda X:(X[0],-X[1],X[2]))
#print(L)
X = 0
for i in range(1,n):
    if L[i][1]<=L[i-1][1]:
        print(L[i][2],L[i-1][2])
        X = 1
        break
if X == 0:
    print(-1,-1)

#!/usr/bin/env python3

n = int(input().strip())
ais = [tuple(map(int, input().strip().split())) for _ in range(n)]

def solve(ais):
	bis = [(l, r, i + 1) for i, (l, r) in enumerate(ais)]
	bis.sort(key=lambda t: (t[0], -t[1]))
	rr = bis[0][1] - 1
	ir = bis[0][2]
	for l, r, i in bis:
		if r <= rr:
			return (i, ir)
		else:
			rr = r
			ir = i
	return (-1, -1)
		

i, j = solve(ais)
print(i, j)


n = int(input())

segments = []

for i, _ in enumerate(range(n)):
    a, b = map(int, input().split())
    segments.append(((a, b), i + 1))

segments.sort(key=lambda x: (x[0][0], -x[0][1]))

last_r = 0
last_index = 0

for segment, index in segments:
    if last_r >= segment[1]:
        print(index, last_index)
        break

    last_r = segment[1]
    last_index = index
else:
    print(-1, -1)

def res(d,N):
    for i in range(1,N):
        if d[i][1] <= d[i-1][1]:
            return str(d[i][2]+1) + ' ' + str(d[i-1][2]+1)
    return '-1 -1'    

N = int(input())
d = []
for i in range(N):
    a,b = list(map(int,input().split()))
    d.append((a,b,i))
d = sorted(d, key = lambda x:(x[0],-x[1]))
print(res(d,N))


import sys

def inn(a,b):
	return (a[0] <= b[0] and b[1] <= a[1])

n = int(input())

seg = []

a,b = map(int,input().split())
seg.append((a,b,1))

for i in range(2,n+1):
	a,b = map(int,input().split())
	seg.append((a,b,i))
	
seg.sort(key=lambda x : (x[0],-x[1]))

main = seg.pop(0)
	
for i in seg:
	if inn(main,i):
		print(i[2],main[2])
		return
	if main[1] < i[1]:
		main = i

print(-1,-1)

def solution():
    
    n = int(input())
    segments = []
    for i,_ in enumerate(range(n)):
        x,y = input().split(" ")
        segments.append((int(x), int(y), i+1))

    segments = sorted(segments, key=lambda x: (x[0], -x[1]))

    for i,seg in enumerate(segments):
        j = i+1
        if j >= n:
            print("-1 -1")
            return

        while segments[j][1] <= seg[1]:
            print("{} {}".format(segments[j][2], seg[2]))
            return

    print("-1 -1")
    return

solution()


n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int,input().split()))+[i])
a.sort(key=lambda f:(f[0],-f[1]))
for i in range(n-1):
    if a[i][1]>=a[i+1][1]:
        print(a[i+1][2]+1,a[i][2]+1)
        break
else:
    print(-1,-1)















n = int(input())
pairs = [list(map(int, input().split()))+[i] for i in range(n)]
pairs.sort(key=lambda x:(x[0], -x[1]))
for i in range(1, n):
    if pairs[i][1] <= pairs[i-1][1]:
        print(pairs[i][2]+1, pairs[i-1][2]+1)
        break
else:
    print(-1, -1)

import sys
n = int(sys.stdin.readline())

intervals = list([(int(x[0]), int(x[1])) for x in list(map(str.split, sys.stdin.readlines()))])
intervals = list(enumerate(intervals))

intervals.sort(key=lambda x : 1000000009 * x[1][0] - x[1][1])

r = 0
ans1 = -1
ans2 = -1
for interval in intervals:
    if interval[1][1] <= r:
        ans1 = interval[0]
        break
    else:
        ans2 = interval[0]
        r = interval[1][1]

if ans1 == -1:
    print('-1 -1')
else:
    print(ans1 +1, ans2 +1)


def main():
    n = int(input())
    seg = []
    for i in range(n):
        l, r = map(int, input().split())
        seg.append((l, r, i+1))

    seg = sorted(seg, key=lambda x: (x[0], -x[1]))

    lar = 0
    sma = -1
    for i in range(1, len(seg)):
        if seg[i][1] <= seg[lar][1]:
            sma = i
            break
        else:
            lar = i
    if sma != -1:
        print(seg[sma][2], seg[lar][2])
    else:
        print(-1, -1)



def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3
from sys import stdin, stdout

def rint():
    return list(map(int, stdin.readline().split()))

n = int(input())

a = [list(rint()) + [i+1] for i in range(n)]

a.sort(key=lambda aa: [aa[0], -aa[1], aa[2]])

start = [-1, -1, -1]

for aa in a:
    if start[1] >= aa[1]:
        ans = [aa[2], start[2]]
        print(*ans)
        return
    else:
        start = aa

print(-1, -1)




n=int(input())
a=sorted((l,-r,i)for i,(l,r)in
enumerate((map(int,input().split())for _ in[0]*n),1))
print(*next(((y[2],x[2])for x,y in zip(a,a[1:])if x[1]<=y[1]),(-1,-1)))

n=int(input())
a=sorted((l,-r,i)for l,r,i in(map(int,input().split()+[i+1])for i in range(n)))
print(*next(((y[2],x[2])for x,y in zip(a,a[1:])if x[1]<=y[1]),(-1,-1)))

from operator import itemgetter
def cmpnr(a, b):
    if a[0] < b[0]:
        return True
    if a[0] > b[0]:
        return False
    return a[1] > b[1]

n = int(input())
seg = []
for i in range(n):
    a, b = list(map(int, input().split()))
    seg.append((a, b, i + 1))

seg = sorted(seg, key=lambda t: (t[0], -t[1]))

maxr = 0
maxri = 0
for a, b, i in seg:
    if b <= maxr:
        print(i, maxri)
        return

    if b > maxri:
        maxr = b
        maxri = i

print(-1, -1)