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: MEDIUM

Solutions:
n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append([l, r, i + 1])
a.sort(key=lambda f: (f[0], -f[1]))
large = 0
for i in range(1, n):
	if a[i][1] <= a[large][1]:
		print(str(a[i][2]) + ' ' + str(a[large][2]))
		exit()
	else:
		large = i
print('-1 -1')


import sys
input = sys.stdin.readline
n = int(input())
lista = []
for j in range(n):
	(l, r) = map(int, input().split())
	lista.append([l, r, j + 1])
lista.sort(key=lambda X: (X[0], -X[1], X[2]))
ok = False
for i in range(1, len(lista)):
	if lista[i - 1][0] <= lista[i][0] and lista[i - 1][1] >= lista[i][1]:
		print(lista[i][2], lista[i - 1][2])
		ok = True
		break
if ok == False:
	print(-1, -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()


import sys
input = sys.stdin.readline
n = int(input())
ls = []
for i in range(n):
	(l, r) = list(map(int, input().strip().split()))
	ls.append([l, r, i])
ls = sorted(ls, key=lambda x: (x[0], -x[1]))
flag = False
mmax = -1
arg_mother = 0
for i in range(n):
	(cur_l, cur_r, child) = ls[i]
	if cur_r <= mmax:
		print(child + 1, arg_mother + 1)
		flag = True
		break
	else:
		mmax = cur_r
		arg_mother = ls[i][2]
if not flag:
	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)


n = int(input())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append((x, y, i + 1))
a.sort(key=lambda aa: (aa[0], -aa[1]))
m = 0
for i in range(1, n):
	if a[i][1] > a[m][1]:
		m = i
	else:
		print('%i %i' % (a[i][2], a[m][2]))
		exit()
print('-1 -1')


import sys
R = lambda : map(int, sys.stdin.buffer.readline().split())
n = list(R())[0]
a = []
for i in range(n):
	(x, y) = R()
	a.append((x, -y, i + 1))
a.sort()
ans = (-1, -1)
for x in range(1, len(a)):
	if a[x][1] >= a[x - 1][1]:
		ans = (a[x][2], a[x - 1][2])
		break
print(*ans)


import sys
input = sys.stdin.readline
n = int(input())
lr = [(i,) + tuple(map(int, input().split())) for i in range(n)]
lr.sort(key=lambda k: (k[1], -k[2]))
for i in range(n - 1):
	if lr[i + 1][2] <= lr[i][2]:
		print(lr[i + 1][0] + 1, lr[i][0] + 1)
		exit()
print(-1, -1)


from sys import stdin
n = int(stdin.readline())
r = 1
arr = []
for i in range(n):
	(x, y) = map(int, stdin.readline().split())
	arr.append((x, -y, r))
	r += 1
la = sorted(arr, key=lambda x: (x[0], x[1]))
for i in range(1, n):
	if la[i - 1][1] <= la[i][1]:
		print(la[i][2], la[i - 1][2])
		exit()
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))


def main():
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())) + [i + 1])
	arr.sort(key=lambda x: [x[0], -x[1]])
	ind = 0
	for i in range(1, len(arr)):
		if arr[ind][1] >= arr[i][1]:
			print(arr[i][2], arr[ind][2])
			return
		else:
			ind = i
	print(-1, -1)
main()


def solve():
	n = int(input())
	segs = []
	for _ in range(n):
		(s, e) = map(int, input().split())
		segs.append((s, e, _ + 1))
	segs.sort(key=lambda x: (x[0], -x[1]))
	max_right = 0
	big_seg = -1
	for (i, seg) in enumerate(segs):
		if seg[1] <= max_right:
			print(seg[2], segs[big_seg][2])
			return
		else:
			max_right = seg[1]
			big_seg = i
	print(-1, -1)
solve()


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()


import sys
n = int(sys.stdin.buffer.readline().decode('utf-8'))
seg = sorted((list(map(int, line.decode('utf-8').split())) + [i] for (i, line) in enumerate(sys.stdin.buffer)), key=lambda x: (x[0], -x[1]))
(right, j) = (-1, -1)
for (_, r, i) in seg:
	if r <= right:
		print(i + 1, j)
		exit()
	right = r
	j = i + 1
print(-1, -1)


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)


from sys import stdin
n = int(stdin.readline().strip())
s = []
for i in range(n):
	(a, b) = map(int, stdin.readline().strip().split())
	s.append((a, -b, i + 1))
s.sort()
a = -1
b = -1
for i in range(n - 1):
	if s[i][0] <= s[i + 1][0] and s[i][1] <= s[i + 1][1]:
		a = s[i][2]
		b = s[i + 1][2]
		break
print(b, a)


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)


from sys import stdin

class segment:

	def __init__(self, x, y, n):
		self.a = x
		self.b = y
		self.no = n

	def __gt__(self, other):
		if self.a == other.a:
			return self.b < other.b
		return self.a > other.a

	def __lt__(self, other):
		if self.a == other.a:
			return self.b > other.b
		return self.a < other.a

	def __eq__(self, other):
		if self.a == other.a and self.b == self.b:
			return True
		else:
			return False

	def __str__(self):
		return str(self.no)
n = int(stdin.readline())
arr = []
for i in range(n):
	(r, z) = map(int, stdin.readline().split())
	s = segment(r, z, i + 1)
	arr.append(s)
arr.sort()
for i in range(1, n):
	if arr[i].b <= arr[i - 1].b:
		print(arr[i], arr[i - 1])
		exit()
print(-1, -1)


n = int(input())
L = []
for i in range(n):
	L.append(list(map(int, input().split())) + [i + 1])
L.sort(key=lambda X: (X[0], -X[1], X[2]))
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)


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)


n = int(input())
d = []
for _ in ' ' * n:
	(x, y) = map(int, input().split())
	d.append([x, -y])
m = a = 0
s = sorted(range(n), key=lambda x: d[x])
for i in s:
	y = d[i][1]
	if y >= m:
		print(i + 1, a + 1)
		exit(0)
	else:
		m = y
		a = i
print(-1, -1)


def solve():
	n = int(input())
	segs = []
	for i in range(n):
		t = tuple(map(int, input().split()))
		segs.append((*t, i))
	segs.sort(key=lambda t: (t[0], -t[1]))
	maxindex = 0
	maxright = 0
	for t in segs:
		if t[1] <= maxright:
			return (t[2] + 1, maxindex + 1)
		else:
			maxindex = t[2]
			maxright = t[1]
	return (-1, -1)
print(*solve())


from sys import stdin, stdout

def rint():
	return 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)
		exit()
	else:
		start = aa
print(-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)))


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


n = int(input())
l = [i for i in range(n)]
d = [tuple(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x: (d[x][0], -d[x][1]))
for i in range(n - 1):
	if d[l[i + 1]][1] <= d[l[i]][1]:
		print(l[i + 1] + 1, l[i] + 1)
		exit()
print(-1, -1)


n = int(input())
L = []
for i in range(n):
	(l, r) = map(int, input().split())
	L.append((l, -r, i + 1))
L = sorted(L)
f = 0
for i in range(1, n):
	if L[i - 1][1] <= L[i][1]:
		f = 1
		print(L[i][2], L[i - 1][2])
		break
if f == 0:
	print(-1, -1)


import sys
input = sys.stdin.readline
n = int(input())
c = []
for _ in range(n):
	(a, b) = map(int, input().split())
	c.append((a, b, _))
c.sort(key=lambda x: (x[0], -x[1]))
a = c[0][1]
b = c[0][2]
an1 = -1
an2 = -1
for i in range(1, n):
	if c[i][1] <= a:
		an2 = b + 1
		an1 = c[i][2] + 1
		break
	else:
		a = c[i][1]
		b = c[i][2]
print(an1, an2)


import heapq as hq
seq = []
n = int(input())
for i in range(n):
	[l, r] = [int(x) for x in input().split()]
	seq.append((l, -r, i + 1))
seq.sort()
ans = (-1, -1)
for i in range(n - 1):
	if seq[i][1] <= seq[i + 1][1]:
		ans = (seq[i + 1][2], seq[i][2])
		break
print(ans[0], ans[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)


n = int(input())
segs = []
for i in range(n):
	(a, b) = map(int, input().split())
	segs.append([a, b, i])
segs.sort(key=lambda x: [x[0], -x[1]])
for i in range(1, n):
	if segs[i][1] <= segs[i - 1][1]:
		print(segs[i][2] + 1, segs[i - 1][2] + 1)
		exit()
segs.sort(key=lambda x: [-x[1], x[0]])
for i in range(1, n):
	if segs[i][0] >= segs[0][0]:
		print(segs[i][2] + 1, segs[0][2] + 1)
		exit()
print('-1 -1')


n = int(input())
segs = []
for seg in range(n):
	(a, b) = map(int, input().split())
	segs.append((a, -b, seg + 1))
segs.sort()
for i in range(1, n):
	e = segs[i]
	if e[1] >= segs[i - 1][1]:
		print(segs[i][2], segs[i - 1][2])
		break
else:
	print(-1, -1)


def main():
	n = int(input())
	segs = []
	for i in range(n):
		inpt = list(map(int, input().split()))
		segs.append((inpt[0], inpt[1], i + 1))
	segs.sort(key=lambda x: x[1], reverse=True)
	segs.sort(key=lambda x: x[0])
	old = segs[0]
	for i in range(1, n):
		current = segs[i]
		if current[1] <= old[1]:
			print(str(current[2]) + ' ' + str(old[2]))
			exit(0)
		elif old[1] < current[1]:
			old = current
	print(str(-1) + ' ' + str(-1))
main()


n = int(input())
a = []
for i in range(1, n + 1):
	(l, r) = 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)
		exit()
	else:
		hh = a[i][1]
		wahh = a[i][2]
print(-1, -1)