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.


-----Examples-----
Input
3
1 1
2 2
3 3

Output
-1

Input
6
1 5
2 3
1 10
7 10
7 7
10 10

Output
3

Difficulty: EASY
Tags: Sorting

Implementation
Skill types: Sorting

Starter code:

Solutions:
num_segment = int(input())
segment_list = []
for i in range(num_segment):
	a = input()
	a = list(map(int, a.split()))
	segment_list.append(a)
min_val = segment_list[0][0]
max_val = segment_list[0][1]
result = -1
for segment in segment_list:
	if segment[0] < min_val:
		min_val = segment[0]
	if segment[1] > max_val:
		max_val = segment[1]
for segment in segment_list:
	if segment[0] == min_val and segment[1] == max_val:
		result = segment_list.index(segment) + 1
print(result)


n = int(input())
(l, r) = ([], [])
Lmin = 1000000000.0
Rmax = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
	Lmin = min(Lmin, l[i])
	Rmax = max(Rmax, r[i])
flag = 0
for i in range(0, n):
	if l[i] == Lmin and r[i] == Rmax:
		flag = 1
		print(i + 1)
if flag == 0:
	print(-1)


n = int(input())
r = []
for i in range(n):
	r += [list(map(int, input().split()))]
m = r[:]
m.sort(key=lambda x: x[0])
a = m[0][0]
m.sort(key=lambda x: x[1], reverse=True)
b = m[0][1]
t = [a, b]
if t in m:
	print(r.index(t) + 1)
else:
	print('-1')


def main():
	a = [list(map(int, input().split())) for _ in ' ' * int(input())]
	l = min([x[0] for x in a])
	r = max([x[1] for x in a])
	try:
		print(a.index([l, r]) + 1)
	except ValueError:
		print(-1)
main()


n = int(input())
x = []
for i in range(n):
	(a, b) = [int(h) for h in input().split()]
	x.append([a, i + 1])
	x.append([b, i + 1])
x.sort()
start_wale = set()
end_wale = set()
if n == 1:
	print(1)
elif n >= 2:
	start = 0
	while True:
		if start >= n:
			break
		elif x[start][0] != x[start + 1][0]:
			break
		else:
			start_wale.add(x[start][1])
			start += 1
	start_wale.add(x[start][1])
	end = -1
	while True:
		if end <= -(n + 1):
			break
		elif x[end][0] != x[end - 1][0]:
			break
		else:
			end_wale.add(x[end][1])
			end -= 1
	end_wale.add(x[end][1])
	xx = start_wale.intersection(end_wale)
	if len(xx) == 0:
		print(-1)
	else:
		print(xx.pop())


number = int(input())
coordinates = []
x = []
y = []
for i in range(number):
	coordinate = input().split(' ')
	coordinates.append(coordinate)
	x.append(int(coordinate[0]))
	y.append(int(coordinate[1]))
min_x = min(x)
max_y = max(y)
res = -1
for i in range(number):
	if int(coordinates[i][0]) == min_x and int(coordinates[i][1]) == max_y:
		res = i + 1
		break
print(res)


n = int(input())
minl = 10000000000000
maxr = -1000000000000
ll = []
rr = []
for i in range(n):
	(l, r) = map(int, input().split())
	ll.append(l)
	rr.append(r)
	if l < minl:
		minl = l
	if r > maxr:
		maxr = r
f = 0
for i in range(n):
	if ll[i] <= minl and rr[i] >= maxr:
		f = 1
		print(i + 1)
if f == 0:
	print(-1)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(stdin.readline())
P = 1000000007
n = I()
arr = []
(mn, mx) = (P, 0)
for i in range(n):
	(x, y) = In()
	arr.append((x, y))
	mn = min(mn, x)
	mx = max(mx, y)
if (mn, mx) in arr:
	print(arr.index((mn, mx)) + 1)
else:
	print(-1)


num = int(input())
l = []
k = []
mi = 100000000000
ma = 0
for i in range(num):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a < mi:
		mi = a
	if b > ma:
		ma = b
	l.append((a, b))
if (mi, ma) in l:
	print(l.index((mi, ma)) + 1)
else:
	print('-1')


def inputArr(num):
	arr = []
	for i in range(num):
		arr.append(input().split())
	return arr

def getMinMax(arr):
	maxRight = 0
	minLeft = int(arr[0][0])
	for i in range(len(arr)):
		if minLeft >= int(arr[i][0]):
			minLeft = int(arr[i][0])
		if maxRight <= int(arr[i][1]):
			maxRight = int(arr[i][1])
	return (minLeft, maxRight)
num = int(input())
arr = inputArr(num)
(minLeft, maxRight) = getMinMax(arr)
linhcanh = 1
for i in range(num):
	if minLeft == int(arr[i][0]):
		if maxRight == int(arr[i][1]):
			print(i + 1)
			linhcanh = 0
if linhcanh == 1:
	print(-1)


numberOfSegment = int(input())
listOfSegment = []
listOfValueSegment = []
maxValue = -1
minValue = -1
for index in range(numberOfSegment):
	listOfSegment.append(input().split())
for segment in listOfSegment:
	for value in segment:
		listOfValueSegment.append(int(value))
for value in listOfValueSegment:
	if maxValue < value:
		maxValue = value
	if minValue == -1 or minValue > value:
		minValue = value
finalSegment = [str(minValue), str(maxValue)]
print(str(listOfSegment.index(finalSegment) + 1) if finalSegment in listOfSegment else str(-1))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = [LI() for _ in range(n)]
		l = min((_[0] for _ in a))
		r = max((_[1] for _ in a))
		t = -1
		for (i, b) in enumerate(a, 1):
			if b[0] == l and b[1] == r:
				t = i
				break
		rr.append(t)
	return JA(rr, '\n')
print(main())


n = int(input())
minLeft = 1000000000
maxRight = 0
minPos = 0
maxPos = 0
for i in range(n):
	(l, r) = map(int, input().split())
	if l < minLeft:
		minLeft = l
		minPos = i
	if r > maxRight:
		maxRight = r
		maxPos = i
	if l == minLeft and r >= maxRight:
		minPos = i
		maxPos = i
	if l <= minLeft and r == maxRight:
		minPos = i
		maxPos = i
if minPos != maxPos:
	print(-1)
else:
	print(minPos + 1)


n = int(input())
(mn, mx) = (1000000024, -1)
a = []
for i in range(n):
	(l, r) = [int(t) for t in input().split()]
	mn = min(mn, l)
	mx = max(mx, r)
	a.append([l, r, i + 1])
for i in a:
	if i[0] == mn and i[1] == mx:
		print(i[2])
		quit(0)
print(-1)


def locate_min(a):
	smallest = min(a)
	return (smallest, [index for (index, element) in enumerate(a) if smallest == element])

def locate_max(a):
	biggest = max(a)
	return (biggest, [index for (index, element) in enumerate(a) if biggest == element])

def find_covered_segment_index(number_of_segment, array_1, array_2):
	min_index = locate_min(array_1)[1]
	max_index = locate_max(array_2)[1]
	intersection = list(set(min_index) & set(max_index))
	result = -1 if len(intersection) == 0 else intersection[0] + 1
	return result
number_of_segment = int(input())
array_1 = []
array_2 = []
for i in range(0, number_of_segment):
	temp_list = [int(j) for j in input().split()]
	array_1.append(temp_list[0])
	array_2.append(temp_list[1])
print(find_covered_segment_index(number_of_segment, array_1, array_2))


n = int(input())
a = []
for i in range(n):
	temp = list(map(int, input().split()))
	a.append(temp)
minL = a[0][0]
for i in range(n):
	if a[i][0] <= minL:
		minL = a[i][0]
maxR = a[0][1]
for i in range(n):
	if a[i][1] >= maxR:
		maxR = a[i][1]
k = -1
for i in range(n):
	if a[i][0] == minL and a[i][1] == maxR:
		k = i
if k != -1:
	print(k + 1)
else:
	print(k)


class CodeforcesTask242BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.segments = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.segments.append([int(y) for y in input().split(' ')])

	def process_task(self):
		starts = [x[0] for x in self.segments]
		stops = [x[1] for x in self.segments]
		start = min(starts)
		stop = max(stops)
		self.result = '-1'
		for x in range(self.n):
			if self.segments[x][0] <= start and self.segments[x][1] >= stop:
				self.result = str(x + 1)

	def get_result(self):
		return self.result
Solution = CodeforcesTask242BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
left = min(l)
right = max(r)
index = -1
for i in range(n):
	if l[i] == left and r[i] == right:
		index = i + 1
print(index)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(0, n):
	(l[i], r[i]) = map(int, input().split())
leftEnd = min(l)
rightEnd = max(r)
for i in range(0, n):
	if leftEnd == l[i] and rightEnd == r[i]:
		print(i + 1)
		exit()
print(-1)


import os
import sys, math
from io import BytesIO, IOBase

def main():
	t = 1
	for case in range(t):
		n = int(input())
		mxl = 0
		mxr = 0
		mnl = math.inf
		mnr = math.inf
		arr = []
		for i in range(n):
			(l, r) = list(map(int, input().split()))
			arr.append([l, r])
			mxl = max(mxl, l)
			mnl = min(mnl, l)
			mxr = max(mxr, r)
			mnr = min(mnr, r)
		ans = -2
		ix = 0
		for tup in arr:
			(x, y) = (tup[0], tup[1])
			if mxl >= x and mxl <= y and (mnl >= x) and (mnl <= y) and (mxr >= x) and (mxr <= y) and (mnr >= x) and (mnr <= y):
				ans = ix
			ix += 1
		print(ans + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
ans = 0
(a, b) = (0, 0)
(mina, maxb) = list(map(int, input().split()))
for i in range(1, n):
	(a, b) = list(map(int, input().split()))
	if a < mina:
		mina = a
		ans = -1
	if b > maxb:
		maxb = b
		ans = -1
	if a == mina and b == maxb:
		ans = i
if ans == -1:
	print(ans)
else:
	print(ans + 1)


n = int(input())
result = -1
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if i == 0:
		c = a
		d = b
	if a < c:
		c = a
		result = -1
	if d < b:
		d = b
		result = -1
	if a == c and b == d:
		result = i + 1
print(result)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
min = l[0][0]
max = l[0][0]
check = True
for i in l:
	if i[0] < min:
		min = i[0]
	if i[1] > max:
		max = i[1]
for i in range(len(l)):
	if l[i][0] == min and l[i][1] == max:
		print(i + 1)
		check = False
if check:
	print(-1)


def Slove():
	n = int(input())
	l = [0] * n
	r = [0] * n
	for i in range(n):
		(l[i], r[i]) = map(int, input().split())
	(left, right) = (min(l), max(r))
	for i in range(n):
		if left == l[i] and right == r[i]:
			return i + 1
	return -1
print(Slove())


n = int(input())
L = [0] * n
R = [0] * n
for i in range(n):
	(L[i], R[i]) = map(int, input().split(' '))
left = min(L)
right = max(R)
for i in range(n):
	if left == L[i] and right == R[i]:
		print(i + 1)
		exit()
print(-1)


n = int(input())
pts = []
for _ in range(n):
	pts.append(list(map(int, input().split())))
mmin = min(pts, key=lambda x: x[0])
mmax = max(pts, key=lambda x: x[1])
ans = -1
for i in range(n):
	if pts[i][0] <= mmin[0] and pts[i][1] >= mmax[1]:
		ans = i + 1
print(ans)


n = int(input())
left = [None] * n
right = [None] * n
for i in range(n):
	(left[i], right[i]) = map(int, input().split())
answer = -1
minL = 10 ** 9 + 1
for i in range(n):
	if left[i] < minL:
		minL = left[i]
maxR = 0
for i in range(n):
	if right[i] > maxR:
		maxR = right[i]
for i in range(n):
	if left[i] == minL and right[i] == maxR:
		answer = i + 1
print(answer)


n = int(input())
a = []
b = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(l)
	b.append(r)
Left = min(a)
Right = max(b)
for i in range(n):
	if a[i] == Left and b[i] == Right:
		print(i + 1)
		exit()
print(-1)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
mn = min(l)
mx = max(r)
ans = -1
for i in range(n):
	if l[i] == mn and r[i] == mx:
		ans = i + 1
print(ans)


from sys import stdin, stdout, setrecursionlimit
from gc import disable
gets = input
puts = print
input = stdin.readline
print = stdout.write

def main() -> int:
	disable()
	n = int(input())
	ma = -1
	mi = 10 ** 10
	s = []
	for i in range(n):
		(l, r) = map(int, input().split())
		if l < mi:
			mi = l
		if r > ma:
			ma = r
		s.append((l, r))
	try:
		print('%i' % (1 + s.index((mi, ma))))
	except:
		print('-1')
	return 0
main()


n = int(input())
m = []
for i in range(n):
	(a, b) = map(int, input().split())
	m.append([a, b])
mi = min([x[0] for x in m])
ma = max([x[1] for x in m])
seg = [mi, ma]
if seg in m:
	print(m.index(seg) + 1)
else:
	print(-1)


def findNumberCover(matrix):
	min_value = min(matrix[0])
	listMin = [i for (i, j) in enumerate(matrix[0]) if j == min_value]
	max_value = max(matrix[1])
	listMax = [i for (i, j) in enumerate(matrix[1]) if j == max_value]
	result = list(set(listMin).intersection(listMax))
	if not result:
		return -1
	else:
		return result[0] + 1

def transpose(matrix):
	matrixT = []
	row1 = []
	row2 = []
	for index in matrix:
		row1.append(index[0])
		row2.append(index[1])
	matrixT.append(row1)
	matrixT.append(row2)
	return matrixT
rows = int(input())
matrix = []
row = []
for i in range(rows):
	row = list(map(int, input().split()))
	matrix.append(row)
matrixT = transpose(matrix)
print(findNumberCover(matrixT))


n = int(input().strip())
left_list = []
right_list = []
for i in range(n):
	(l, r) = map(int, input().split())
	left_list.append(l)
	right_list.append(r)
i = 0
min_value = min(left_list)
max_value = max(right_list)
result = -1
while i < n:
	if min_value == left_list[i] and max_value == right_list[i]:
		result = i + 1
		break
	i += 1
print(str(result))


def main():
	n = int(input())
	(mi, ma) = (10000000001, 0)
	l = []
	for _ in range(n):
		(a, b) = map(int, input().split())
		if mi > a:
			mi = a
		if ma < b:
			ma = b
		l.append((a, b))
	l.append((mi, ma))
	idx = l.index((mi, ma))
	print(-1 if idx == n else idx + 1)
main()


def big_segment(right, left):
	highest = max(left)
	lowest = min(right)
	for i in range(len(right)):
		if right[i] == lowest and left[i] == highest:
			return i + 1
	return -1
n = int(input())
left = []
right = []
for i in range(n):
	(r, l) = map(int, input().split())
	right.append(r)
	left.append(l)
print(big_segment(right, left))


n = int(input())
l = []
(a, b) = (10 ** 9 + 1, 0)
(c, d) = (10 ** 9 + 1, 0)
for i in range(n):
	(x, y) = map(int, input().split())
	c = min(c, x)
	d = max(d, y)
	if x <= a and y >= b:
		a = x
		b = y
		index = i + 1
if c == a and d == b:
	print(index)
else:
	print('-1')


n = int(input())
mini = None
maxi = None
b = []
for i in range(n):
	(l, r) = map(int, input().split())
	if mini is None or l < mini:
		mini = l
	if maxi is None or r > maxi:
		maxi = r
	b.append([l, r])
print(b.index([mini, maxi]) + 1 if [mini, maxi] in b else -1)


num_segments = int(input())
start_segments = []
end_segments = []

def find_max_of_end(my_list):
	max = my_list[0]
	for (index, item) in enumerate(my_list):
		if item > max:
			max = item
	return max

def find_index_of_min(my_list):
	min = my_list[0]
	min_indexs = []
	for (index, item) in enumerate(my_list):
		if item < min:
			min = item
	for (index, item) in enumerate(my_list):
		if item == min:
			min_indexs.append(index)
	return min_indexs
for _ in range(num_segments):
	(start, end) = list(map(int, input().split()))
	start_segments.append(start)
	end_segments.append(end)
min_start_indexes = find_index_of_min(start_segments)
max_end = find_max_of_end(end_segments)
result = -1
for index in min_start_indexes:
	if end_segments[index] == max_end:
		result = index
		break
if result == -1:
	print(result)
else:
	print(result + 1)


def Q(x):
	return x[1] - x[0] + 1
n = int(input())
L = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	L.append((x, y, i + 1))
L.sort(key=Q, reverse=True)
ans = L[0][2]
for i in range(1, n):
	if L[i][0] >= L[0][0] and L[i][1] <= L[0][1]:
		continue
	ans = -1
print(ans)


n = int(input())
array = []
for i in range(n):
	array.append(list(map(int, input().split())))
ans = True
maxi = array[0][1]
mini = array[0][0]
index = 1
for i in range(1, n):
	x = array[i][0]
	y = array[i][1]
	if x <= mini and y >= maxi:
		maxi = y
		mini = x
		index = i + 1
		ans = True
		continue
	if x < mini:
		mini = x
		index = -1
		ans = False
	if y > maxi:
		maxi = y
		index = -1
		ans = False
if ans == False:
	print(-1)
else:
	print(index)


n = int(input())
ret = -1
left = []
right = []
for i in range(n):
	(a, b) = map(int, input().split(' '))
	left.append(a)
	right.append(b)
ml = left[0]
mr = right[0]
for i in range(n):
	if left[i] < ml:
		ml = left[i]
	if right[i] > mr:
		mr = right[i]
for i in range(n):
	if left[i] <= ml and mr <= right[i]:
		ret = i + 1
print(ret)


n = int(input())
(v, m) = ([], [])
while n:
	(a, b) = [int(y) for y in input().split()]
	v.append(a)
	m.append(b)
	n -= 1
menor = 100000000000
maior = -1
indice = 0
indice1 = 0
for i in range(len(v)):
	if v[i] <= menor and m[i] >= maior:
		menor = v[i]
		indice = i + 1
	if m[i] >= maior and v[i] == menor:
		maior = m[i]
		indice1 = i + 1
	if m[i] >= maior:
		maiorReserva = m[i]
if maiorReserva > maior:
	indice = 0
v.sort()
m.sort()
if v[0] != menor or m[-1] != maior:
	indice = -1
print(indice if indice == indice1 else '-1')


n = int(input())
x_list = []
y_list = []
dictionary = {}
for i in range(n):
	(x, y) = map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	dictionary[x, y] = i + 1
x_list.sort()
y_list.sort(reverse=True)
if (x_list[0], y_list[0]) in dictionary.keys():
	print(dictionary[x_list[0], y_list[0]])
else:
	print(-1)


n = int(input())
s = list()
mx = 0
for i in range(n):
	(a, b) = map(int, input().split())
	mx = max(mx, b)
	s.append((a, b))
t = sorted(s, key=lambda x: (x[0], -x[1]))
print(s.index(t[0]) + 1 if t[0][1] == mx else '-1')


(x, y) = ([], [])
n = int(input())
for _ in range(n):
	line = list(map(int, input().split()))
	x.append(line[0])
	y.append(line[1])
min_val = min(x)
max_val = max(y)
flag = 1
c = 0
for (i, j) in zip(x, y):
	c += 1
	if i == min_val and j == max_val:
		print(c)
		flag = 0
		break
if flag:
	print('-1')


n = int(input())
ls = []
expected_seg = [10 ** 9, 1]
flag = False
for i in range(n):
	temp = list(map(int, input().split()))
	if temp[0] < expected_seg[0]:
		expected_seg[0] = temp[0]
	if temp[1] > expected_seg[1]:
		expected_seg[1] = temp[1]
	ls.append(temp)
pos = 0
for item in ls:
	pos += 1
	if item == expected_seg:
		flag = True
		ans = pos
if flag:
	print(ans)
else:
	print(-1)


n = int(input())
arr = []
ml = 1000000000.0
mr = -1000000000.0
for i in range(n):
	(l, r) = map(int, input().split())
	arr.append([l, r, i + 1])
	ml = min(ml, l)
	mr = max(mr, r)
for i in range(n):
	if arr[i][0] <= ml and arr[i][1] >= mr:
		print(i + 1)
		exit()
print(-1)


import sys
import os
if os.environ.get('GHOST') == 'TRUE':
	sys.stdin = open('name.in')
	sys.stdout = open('name.out', 'w')
N = int(input())
L = set()
R = set()
left = 10 ** 9
right = 0
for i in range(N):
	(l, r) = map(int, input().split())
	if l < left:
		L.clear()
		L.add(i)
		left = l
	elif l == left:
		L.add(i)
	if r > right:
		R.clear()
		R.add(i)
		right = r
	elif r == right:
		R.add(i)
sol = False
for x in L:
	if x in R:
		sol = True
		print(x + 1)
if not sol:
	print(-1)


n = int(input())
A = []
B = []
All = []
for _ in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
	All.append([a, b])
minn = min(A)
maxx = max(B)
found = False
for i in range(n):
	if All[i][0] == minn and All[i][1] == maxx:
		found = True
		print(i + 1)
if not found:
	print(-1)


class doanthang:

	def __init__(self, n, ls):
		self.n = n
		self.ls = ls
		self.idx = 0

	def tim(self):
		min = self.ls[0][0]
		max = self.ls[0][1]
		mx = self.ls[0][1]
		for i in range(1, self.n):
			if min > self.ls[i][0]:
				min = self.ls[i][0]
				max = self.ls[i][1]
				self.idx = i
			elif min == self.ls[i][0] and max < self.ls[i][1]:
				max = self.ls[i][1]
				self.idx = i
			if mx < self.ls[i][1]:
				mx = self.ls[i][1]
		if self.ls[self.idx][1] >= mx:
			return self.idx + 1
		return -1

	def print(self):
		print(self.tim())

def main():
	n = int(input())
	ls = []
	for i in range(n):
		ls.append(list(map(int, input().split())))
	dt = doanthang(n, ls)
	dt.print()
main()


def main():
	n = int(input())
	mi = int(10000000000.0)
	ma = int(-10000000000.0)
	l = []
	for i in range(n):
		(a, b) = map(int, input().split(' '))
		mi = min(mi, a)
		ma = max(ma, b)
		l.append((a, b))
	for (i, (a, b)) in enumerate(l):
		if a == mi and b == ma:
			return i + 1
	return -1
print(main())


def main():
	n = int(input())
	(l, r) = ([], [])
	for _ in range(n):
		(a, b) = map(int, input().split())
		l.append(a)
		r.append(b)
	l.append(min(l))
	r.append(max(r))
	l = list(zip(l, r))
	idx = l.index(l[-1])
	print(-1 if idx == n else idx + 1)
main()


a = []
b = []
n = int(input())
f = 0
d = 0
q = -1
for i in range(n):
	c = input().split()
	a.append(int(c[0]))
	b.append(int(c[1]))
f = min(a)
d = max(b)
for i in range(len(a)):
	if a[i] == f and b[i] == d:
		q = i + 1
print(q)


class Segment:

	def __init__(self, left, right):
		self.left = left
		self.right = right
n = int(input())
max = -1
min = 10000000001
a = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	seg = Segment(l, r)
	a.append(seg)
	if l < min:
		min = l
	if r > max:
		max = r
id = -1
for i in range(n):
	if a[i].left == min and a[i].right == max:
		id = i + 1
print(id)


n = int(input())
(l, r) = ([], [])
for _ in range(n):
	x = [int(i) for i in input().split()]
	l.append(x[0])
	r.append(x[1])
m_i = min(l)
m_a = max(r)
f = -2
i = 0
for (i, x) in enumerate(list(zip(l, r))):
	if x[0] == m_i and x[1] == m_a:
		f = i
		break
print(f + 1)


R = input
I = lambda : map(int, R().split())
n = int(R())
a = []
b = []
for i in range(n):
	(x, y) = I()
	a.append(x)
	b.append(y)
x = min(a)
y = max(b)
for i in range(n):
	if a[i] == x and b[i] == y:
		print(i + 1)
		exit()
print(-1)


n = int(input())
l = []
r = []
k = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
	k.append([a, b])
if [min(l), max(r)] in k:
	print(k.index([min(l), max(r)]) + 1)
else:
	print('-1')


l = list((list(map(int, input().split())) for _ in range(int(input()))))
x = min((i[0] for i in l))
y = max((i[1] for i in l))
if [x, y] in l:
	print(l.index([x, y]) + 1)
else:
	print('-1')


n = int(input())
(l, r) = ([0] * n, [0] * n)
(L, R) = (1000000001, 0)
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
	(L, R) = (min(L, l[i]), max(R, r[i]))
for i in range(n):
	if l[i] == L and r[i] == R:
		print(i + 1)
		quit()
print(-1)


import sys
input = sys.stdin.readline
n = int(input())
niz = 10000000000.0
verh = 0
current = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a <= niz and b >= verh:
		current = i + 1
		niz = a
		verh = b
	elif a < niz and niz <= b <= verh:
		niz = a
		current = -1
	elif a < niz and b < niz:
		niz = a
		current = -1
	elif niz <= a <= verh and verh < b:
		verh = b
		current = -1
	elif verh < a and verh < b:
		verh = b
		current = -1
print(current)


n = int(input())
l = 1000000001
r = 0
found = False
pos = 0
x = [0] * n
y = [0] * n
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
	l = min(l, x[i])
	r = max(r, y[i])
for i in range(n):
	if l == x[i] and r == y[i]:
		found = True
		pos = i + 1
if found:
	print(pos)
else:
	print(-1)


import math
n = int(input())
(_min, _max, segments, answer) = (math.inf, 0, [], -1)
for i in range(n):
	[x, y] = [int(i) for i in input().split()]
	if x < _min or y > _max:
		answer = -1
	_min = _min if _min < x else x
	_max = _max if _max >= y else y
	if x == _min and y == _max:
		answer = i + 1
print(answer)


a = []
b = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
answer = -1
(min_value, max_value) = (min(a), max(b))
for i in range(n):
	if a[i] == min_value and b[i] == max_value:
		answer = i + 1
		break
print(answer)


myList = []

def inp():
	return map(int, input().split(' '))
n = int(input())
vmin = 1000000000
vmax = 0
for i in range(0, n):
	(l, r) = inp()
	myList.append([l, r])
	vmin = min(vmin, l)
	vmax = max(vmax, r)
answer = -1
index = 0
for x in myList:
	index = index + 1
	if vmin == x[0] and vmax == x[1]:
		answer = index
		break
print(answer)


n = int(input())
m = 10000000000000000
z = -1
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	m = min(m, x)
	z = max(z, y)
	a.append([x, y])
for i in range(len(a)):
	if a[i][0] == m and a[i][1] == z:
		print(i + 1)
		break
else:
	print(-1)


import math
n = int(input())
(MIN, MAX, segments, answer) = (math.inf, 0, [], -1)
for i in range(n):
	[x, y] = [int(i) for i in input().split()]
	MIN = MIN if MIN < x else x
	MAX = MAX if MAX >= y else y
	segments.append([x, y])
for (i, s) in enumerate(segments):
	if s[0] == MIN and s[1] == MAX:
		answer = i + 1
		break
print(answer)


(A, B, ans) = (1000000000, 1, -1)
for i in range(1, int(input()) + 1):
	(a, b) = map(int, input().split())
	if a > A:
		if b > B:
			B = b
			ans = -1
	else:
		if b >= B:
			B = b
			ans = i
		elif a != A:
			ans = -1
		A = a
print(ans)


n = int(input())
segments = []
for i in range(n):
	segments.append(list(map(int, input().split(' '))))
tempObject = min(segments, key=lambda x: x[0])
matches = [x for x in segments if tempObject[0] == x[0]]
possibleSegment = max(matches, key=lambda x: x[1])
maxRightSegment = max(segments, key=lambda x: x[1])
if possibleSegment[1] < maxRightSegment[1]:
	print(-1)
	exit()
idx = segments.index(possibleSegment) if possibleSegment in segments else -1
print(idx + 1)


n = int(input())
li = []
(l, r) = (1000000000.0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	(l, r) = (min(l, a), max(r, b))
	li.append([a, b])
res = 0
for i in range(n):
	if li[i][0] <= l and li[i][1] >= r:
		res = i + 1
print(res) if res else print(-1)


n = int(input())
left = []
right = []
smallest = 10 ** 9
biggest = 1
for i in range(n):
	(l, r) = map(int, input().strip().split())
	left.append(l)
	right.append(r)
	if l <= smallest:
		smallest = l
	if r >= biggest:
		biggest = r
for (i, segment) in enumerate(left):
	if segment == smallest and right[i] == biggest:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
lst = []
(minl, maxr) = map(int, input().split())
lst.append([minl, maxr])
for i in range(1, n):
	(l, r) = map(int, input().split())
	lst.append([l, r])
	if l < minl:
		minl = l
	if r > maxr:
		maxr = r
ans = -1
for i in range(len(lst)):
	if lst[i][0] == minl and lst[i][1] == maxr:
		ans = i + 1
print(ans)


n = int(input())
L = [0] * n
R = [0] * n
for i in range(n):
	(L[i], R[i]) = map(int, input().split())
smallest = min(L)
largest = max(R)
for i in range(n):
	if L[i] == smallest and R[i] == largest:
		print(i + 1)
		exit()
print(-1)


set = int(input().split()[0])
segments = []
min = -1
max = -1
for i in range(set):
	segment = list(map(int, input().split()))
	segments.append(segment)
	if min == -1 or segment[0] < min:
		min = segment[0]
	if max == -1 or segment[1] > max:
		max = segment[1]
found = -1
for i in range(set):
	if segments[i][0] <= min and segments[i][1] >= max:
		found = i + 1
print(found)


import math
n = int(input())
l = []
minl = math.inf
maxl = -1
c = -1
for i in range(n):
	x = list(map(int, input().split()))
	if minl >= x[0] and maxl <= x[1]:
		c = i + 1
	elif minl > x[0] or maxl < x[1]:
		c = -1
	minl = min(minl, x[0])
	maxl = max(maxl, x[1])
print(c)


numberOfSegment = int(input())
listOfSegment = []
maxSegment = -1
minSegment = -1
for index in range(numberOfSegment):
	listOfSegment.append(input().split())
for segment in listOfSegment:
	if maxSegment == -1 or maxSegment < int(segment[len(segment) - 1]):
		maxSegment = int(segment[len(segment) - 1])
	if minSegment == -1 or minSegment > int(segment[0]):
		minSegment = int(segment[0])
finalSegment = [str(minSegment), str(maxSegment)]
print(str(listOfSegment.index(finalSegment) + 1) if finalSegment in listOfSegment else str(-1))


from itertools import permutations
n = int(input())
min_x = 999999999
pos = -1
max_y = 0
max_y_g = 0
y_b = []
if n == 1:
	print(1)
	exit(0)
for i in range(n):
	(x, y) = [int(x) for x in input().split(' ')]
	if x <= min_x:
		if x == min_x:
			if y > max_y_g:
				max_y_g = y
				pos = i + 1
		elif min_x > x:
			max_y_g = y
			pos = i + 1
		min_x = x
	if y > max_y:
		max_y = y
if max_y_g != max_y:
	print(-1)
else:
	print(pos)


n = int(input())
l1 = []
r1 = []
l11 = []
for _ in range(n):
	(l, r) = map(int, input().split())
	l1.append(l)
	r1.append(r)
	l11.append([l, r])
mn = min(l1)
mx = max(r1)
i = [mn, mx]
if i in l11:
	print(l11.index(i) + 1)
else:
	print('-1')


n = int(input())
lst = []
max_lenght = -1
index = 0
count = 0
for i in range(n):
	a = list(map(int, input().split()))
	lst.append(a)
	if max_lenght < a[1] - a[0]:
		max_lenght = a[1] - a[0]
		index = i
l = len(lst)
cur = lst.pop(index)
for j in range(len(lst)):
	if cur[0] <= lst[j][0] and lst[j][0] <= lst[j][1] and (lst[j][1] <= cur[1]):
		count += 1
if count == l - 1:
	print(index + 1)
else:
	print(-1)


n = int(input())
s = []
for i in range(n):
	a = list(map(int, input().split()))
	s.append(a)
max = -1
k = 0
t = 0
ans = 0
for i in range(n):
	if s[i][1] > max:
		max = s[i][1]
		k = i
		t = s[i][0]
	elif s[i][1] == max:
		if s[i][0] < t:
			max = s[i][1]
			k = i
			t = s[i][0]
min = 1000000001
for i in range(n):
	if s[i][0] < min:
		min = s[i][0]
if min == t:
	print(k + 1)
else:
	print('-1')


n = int(input())
A = []
for i in range(n):
	A.append([])
	A[i] = list(map(int, input().split()))
li = A[0][0]
ri = -1
res = -1
for i in range(n):
	if A[i][0] < li:
		li = A[i][0]
	if A[i][1] > ri:
		ri = A[i][1]
for i in range(n):
	if A[i][0] == li and A[i][1] == ri:
		res = i
if res == -1:
	print(-1)
else:
	print(res + 1)


n = int(input())
L = [0] * n
R = [0] * n
for i in range(n):
	(L[i], R[i]) = map(int, input().split())
Left = min(L)
Right = max(R)
for i in range(n):
	if L[i] == Left and R[i] == Right:
		print(i + 1)
		exit()
print(-1)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = []
l = float('inf')
r = float('-inf')
for i in range(n):
	(a, b) = iia()
	l = min(l, a)
	r = max(r, b)
	arr.append([a, b])
for i in range(n):
	if arr[i][0] <= l and arr[i][1] >= r:
		print(i + 1)
		break
else:
	print(-1)


number = int(input())
list_array = []
for i in range(number):
	list_array.extend(str(input()).split())
list_array = list(map(int, list_array))
result = -1
minx = min(list_array)
maxx = max(list_array)
a_minx = [i for (i, x) in enumerate(list_array) if x == minx]
for x in a_minx:
	if list_array[x + 1] == maxx:
		result = (x + 2) / 2
		break
print(int(result))


n = int(input())
(left, right) = ([], [])
for x in range(n):
	string = input()
	numbers = string.split()
	left.append(int(numbers[0]))
	right.append(int(numbers[1]))
(a, b) = (min(left), max(right))
for x in range(n):
	if left[x] == a and right[x] == b:
		print(x + 1)
		break
else:
	print(-1)


t = int(input())
l = []
r = []
d = []
for i in range(0, t):
	(a, b) = list(map(int, input().split()))
	l.append(a)
	r.append(b)
	d.append(str(a) + str(b))
a = min(l)
b = max(r)
if str(a) + str(b) in d:
	print(d.index(str(a) + str(b)) + 1)
else:
	print('-1')


n = int(input())
niz = 10000000000.0
verh = 0
current = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a <= niz and b >= verh:
		current = i + 1
		niz = a
		verh = b
	elif a < niz and niz <= b <= verh:
		niz = a
		current = -1
	elif a < niz and b < niz:
		niz = a
		current = -1
	elif niz <= a <= verh and verh < b:
		verh = b
		current = -1
	elif verh < a and verh < b:
		verh = b
		current = -1
print(current)


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
min = l[0]
max = r[0]
for i in range(1, n):
	if min > l[i]:
		min = l[i]
	if max < r[i]:
		max = r[i]
ans = -1
for i in range(n):
	if min == l[i] and max == r[i]:
		ans = i + 1
print(ans)


n = int(input())
a = []
b = []
for i in range(n):
	(tempA, tempB) = map(int, input().split())
	a.append(tempA)
	b.append(tempB)
minx = a[0]
maxx = b[0]
for i in range(1, n, 1):
	minx = min(minx, a[i])
	maxx = max(maxx, b[i])
for i in range(n):
	if a[i] == minx and b[i] == maxx:
		print(i + 1)
		exit()
print(-1)


n = int(input())
minl = 1000000000.0
maxr = 0
l = []
r = []
for i in range(n):
	(le, ri) = map(int, input().split())
	l.append(le)
	r.append(ri)
	if le < minl:
		minl = le
	if ri > maxr:
		maxr = ri
flag = False
for i in range(n):
	if minl == l[i] and maxr == r[i]:
		print(i + 1)
		flag = True
if not flag:
	print(-1)


n = int(input())
segments = []
low = 10 ** 9
high = 1
for i in range(n):
	(l, r) = map(int, input().split())
	low = min(low, l)
	high = max(high, r)
	segments.append((l, r))
ans = -1
for i in range(n):
	if segments[i] == (low, high):
		ans = i + 1
		break
print(ans)


n = int(input())
m1 = 0
m2 = 1000000000
c = []
d = []
a1 = -1
for i in range(n):
	(a, b) = map(int, input().split())
	c.append(a)
	d.append(b)
	if a < m2:
		m2 = a
	if b > m1:
		m1 = b
for i in range(n):
	if c[i] == m2 and d[i] == m1:
		a1 = i + 1
		break
print(a1)


import math

def main():
	n = int(input())
	m = []
	for _ in range(n):
		x = list(map(int, input().split()))
		m.append(x)
	s = m[0][0]
	e = m[0][1]
	q = 0
	for r in range(1, n):
		if m[r][0] <= s and m[r][1] >= e:
			s = m[r][0]
			e = m[r][1]
			q = r
	z = [p[0] for p in m]
	f = [p[1] for p in m]
	if s == min(z) and e == max(f):
		print(q + 1)
	else:
		print(-1)
main()


def segment(lst, lst1):
	pair = [lst1[0], lst1[-1]]
	if pair in lst:
		return lst.index(pair) + 1
	return -1
n = int(input())
(a, b) = (list(), list())
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	a.append([l, r])
	b.append(l)
	b.append(r)
print(segment(a, sorted(b)))


n = int(input())
arr = [tuple(map(int, input().split())) for _ in range(n)]
(a, b) = (float('inf'), 0)
for p in arr:
	a = min(a, p[0])
	b = max(b, p[1])
for i in range(n):
	if arr[i] == (a, b):
		print(i + 1)
		exit()
print(-1)


segment = int(input())
lst = list()
for i in range(segment):
	lst.append(list(map(int, input().split())))
left_segment = list()
right_segment = list()
for item in lst:
	left_segment.append(item[0])
	right_segment.append(item[1])
left_segment.sort()
right_segment.sort()
min_left = left_segment[0]
max_right = right_segment[len(right_segment) - 1]
count = 0
for item in lst:
	count += 1
	if item[0] == min_left and item[1] == max_right:
		print(count)
		break
	if count == len(lst):
		print(-1)


n = int(input())
dict_seg = {}
cover_seg = 1
for i in range(1, n + 1):
	dict_seg[i] = list(map(int, input().split(' ')))
max_seg = dict_seg[1][1]
min_seg = dict_seg[1][0]
for i in range(2, n + 1):
	if min_seg >= dict_seg[i][0] and max_seg <= dict_seg[i][1]:
		min_seg = dict_seg[i][0]
		max_seg = dict_seg[i][1]
		cover_seg = i
for i in range(1, n + 1):
	if min_seg > dict_seg[i][0] or max_seg < dict_seg[i][1]:
		print('-1')
		exit(0)
print(cover_seg)
exit(0)


class Mima:

	def __init__(self, arr, n):
		self.a = arr
		self.n = n
		self.m = []

	def mima(self):
		l = []
		r = []
		for i in range(self.n):
			l.append(self.a[i][0])
			r.append(self.a[i][1])
		return (min(l), max(r))

	def check(self):
		(mi, ma) = self.mima()
		pos = 0
		count = 0
		for i in range(self.n):
			if self.a[i][0] == mi and self.a[i][1] == ma:
				pos = i
			else:
				count += 1
		if count == self.n:
			return -1
		else:
			return pos + 1

def main():
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())))
	re = Mima(arr, n)
	print(re.check())
main()


t = int(input())
listi = [tuple(map(int, input().split())) for x in range(t)]
a = min((tup[0] for tup in listi))
b = max((tup[1] for tup in listi))
if (a, b) in listi:
	print(listi.index((a, b)) + 1)
else:
	print(-1)


a = int(input())
x = []
b = list(map(int, input().split()))
x.append(b)
rb = b[0]
lb = b[1]
for i in range(1, a):
	b = list(map(int, input().split()))
	x.append(b)
	rb = min(rb, b[0])
	lb = max(lb, b[1])
for i in range(a):
	if x[i][0] == rb and x[i][1] == lb:
		print(i + 1)
		quit()
print(-1)


n = int(input())
segments = []
for i in range(n):
	s = input().split(' ')
	segments.append([int(s[0]), int(s[1]), i + 1])
min0 = min(segments, key=lambda val: val[0])
mins0 = [item for item in segments if item[0] == min0[0]]
max1 = max(mins0, key=lambda val: val[1])
max1Parent = max(segments, key=lambda val: val[1])
if max1[1] == max1Parent[1]:
	print(max1[2])
else:
	print('-1')


n = int(input())
s1 = list(map(int, input().split()))
longest = s1
lowest = s1[0]
highest = s1[1]
ret = 0
for i in range(1, n):
	s = list(map(int, input().split()))
	if s[1] - s[0] > longest[1] - longest[0]:
		longest = s
		ret = i
	if s[0] < lowest:
		lowest = s[0]
	if s[1] > highest:
		highest = s[1]
if longest == [lowest, highest]:
	print(ret + 1)
else:
	print(-1)


n = int(input())
segments = []
minL = 1000000000.0
maxR = 0
for i in range(n):
	(l, r) = map(int, input().split())
	minL = min(l, minL)
	maxR = max(r, maxR)
	segments.append((l, r))
cover_segment = -1
for i in range(n):
	s = segments[i]
	if s[0] == minL and s[1] == maxR:
		cover_segment = i + 1
		break
print(cover_segment)


maxx = -1
minn = 10 ** 10
bad = []
a = int(input())
for i in range(a):
	(x, y) = list(map(int, input().split(' ')))
	bad.append([x, y])
	maxx = max(maxx, y)
	minn = min(minn, x)
for i in range(a):
	if bad[i][0] <= minn <= maxx <= bad[i][1]:
		print(i + 1)
		quit()
print(-1)


def main():
	n = int(input())
	segment_upper = []
	segment_lower = []
	for i in range(n):
		(lower, upper) = map(int, input().split())
		segment_upper.append(upper)
		segment_lower.append(lower)
	max_upper = max(segment_upper)
	min_lower = min(segment_lower)
	for i in range(n):
		if segment_upper[i] == max_upper and segment_lower[i] == min_lower:
			return i + 1
	return -1
print(main())


n = int(input())
arr = [tuple(map(int, input().split())) for _ in range(n)]
l = min(arr, key=lambda x: x[0])[0]
h = max(arr, key=lambda x: x[1])[1]
ans = -1
for i in range(n):
	if arr[i][0] == l and arr[i][1] == h:
		ans = i + 1
		break
print(ans)


n = int(input())
(minn, maxn) = (int(i) for i in input().split())
numbers = {(minn, maxn): 0}
for j in range(1, n):
	(a, b) = (int(i) for i in input().split())
	numbers[a, b] = j
	if b > maxn:
		maxn = b
	if a < minn:
		minn = a
if (minn, maxn) in numbers:
	print(numbers[minn, maxn] + 1)
else:
	print(-1)


n = int(input())
l = []
li = []
goon = True
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	li.append(b)
c = min(l)
d = max(li)
for i in range(n):
	if l[i] == c and li[i] == d:
		print(i + 1)
		goon = False
if goon:
	print('-1')


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
Left = min(l)
Right = max(r)
for i in range(n):
	if l[i] == Left and r[i] == Right:
		print(i + 1)
		exit()
print(-1)


n = int(input())
l = []
r = []
min_left = 10 ** 9
max_right = 1
for i in range(n):
	(left, right) = map(int, input().split())
	l.append(left)
	r.append(right)
	min_left = min(min_left, left)
	max_right = max(max_right, right)
pos = -1
for i in range(n):
	if l[i] == min_left and r[i] == max_right:
		pos = i + 1
		break
print(pos)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
low = min(l)
up = max(r)
res = -1
for i in range(n):
	if l[i] == low and r[i] == up:
		res = i + 1
print(res)


n = int(input())
p = 10000000000
q = -1
larr = []
rarr = []
for i in range(n):
	arr = input().split()
	l = int(arr[0])
	r = int(arr[1])
	larr.append(l)
	rarr.append(r)
	if l < p:
		p = l
	if r > q:
		q = r
flag = 0
for i in range(n):
	if larr[i] == p and rarr[i] == q:
		flag = 1
		break
if flag == 1:
	print(str(i + 1))
else:
	print('-1')


n = int(input())
t1 = []
min1 = 10 ** 9 + 1
max1 = 0
for i in range(n):
	a = list(map(int, input().split()))
	min1 = min(min1, a[0])
	max1 = max(max1, a[1])
	t1 += [a]
flag = 0
for i in range(n):
	if t1[i][0] == min1 and t1[i][1] == max1:
		flag = 1
		j = i
		break
if flag == 1:
	print(j + 1)
else:
	print(-1)


n = int(input())
a = []
b = []
for i in range(n):
	s = input().split(' ')
	a.append(int(s[0]))
	b.append(int(s[1]))
minn = min(a)
maxx = max(b)
for i in range(n):
	if a[i] <= minn and b[i] >= maxx:
		print(i + 1)
		exit()
print(-1)


num = -1
R = []
L = []
n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	R.append(r)
	L.append(l)
MAXR = max(R)
MINL = min(L)
for i in range(n):
	if R[i] == MAXR and L[i] == MINL:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
left = l[0]
right = r[0]
for i in range(n):
	if l[i] < left:
		left = l[i]
	if r[i] > right:
		right = r[i]
res = -1
for i in range(n):
	if left == l[i] and right == r[i]:
		res = i + 1
print(res)


n = input()
n = int(n)
pos = -1
segment_areas = []
check = False

def iscovered(bigseg, smallseg):
	return bigseg[0] <= smallseg[0] and bigseg[1] >= smallseg[1]
for i in range(1, n + 1):
	seg = list(map(int, input().split()))
	if not segment_areas:
		segment_areas.append(seg)
	check = False
	for j in range(len(segment_areas)):
		if iscovered(seg, segment_areas[j]):
			segment_areas.pop(j)
			segment_areas.insert(j, seg)
			pos = i
			check = True
		elif iscovered(segment_areas[j], seg):
			break
		if j == len(segment_areas) - 1 and check is False:
			segment_areas.append(seg)
for i in range(1, len(segment_areas)):
	if segment_areas[i] != segment_areas[i - 1]:
		print(-1)
		exit()
print(pos)


import sys, os, io, time, copy
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import math

def main():
	n = int(input())
	arr = []
	for i in range(n):
		(x, y) = map(int, input().split())
		arr.append((x, y))
	m_x = 1000000007
	m_y = -1
	for (x, y) in arr:
		if x < m_x:
			m_x = x
		if y > m_y:
			m_y = y
	pos = -1
	for i in range(n):
		(x, y) = arr[i]
		if x == m_x and y == m_y:
			pos = i + 1
	print(pos)
main()


n = int(input())
num_input = input()
num_input = num_input.split(' ')
minLeft = int(num_input[0])
maxRight = int(num_input[1])
l = [minLeft]
r = [maxRight]
for i in range(1, n):
	num_input = input()
	num_input = num_input.split(' ')
	l.append(int(num_input[0]))
	r.append(int(num_input[1]))
	minLeft = min(minLeft, l[i])
	maxRight = max(maxRight, r[i])
position = -1
for i in range(n):
	if l[i] == minLeft and r[i] == maxRight:
		position = i + 1
		break
print(position)


def main():
	number_of_segments = int(input())
	min_v = 1
	max_v = 1
	idx = -1
	last_segment = []
	max_segment = []
	for i in range(number_of_segments):
		current_segment = [int(i) for i in input().split()]
		last_segment = current_segment
		if i == 0:
			min_v = current_segment[0]
			max_v = current_segment[1]
		if min_v > current_segment[0]:
			min_v = current_segment[0]
		if max_v < current_segment[1]:
			max_v = current_segment[1]
		if (min_v == current_segment[0]) & (max_v == current_segment[1]):
			idx = i
			max_segment = current_segment
	if min_v != max_segment[0] or max_v != max_segment[1]:
		return -1
	if idx == -1:
		return idx
	if idx == 0:
		if min_v <= max_segment[0] <= last_segment[0] <= last_segment[1] <= max_segment[1]:
			return idx + 1
		else:
			return -1
	return idx + 1
print(main())


class Segment:

	def __init__(self, l, r, idx):
		self.l = l
		self.r = r
		self.idx = idx

	def __str__(self):
		return str(self.l) + ' ' + str(self.r) + ' ' + str(self.idx)
MAX = int(1000000000.0 + 1)
n = int(input())
longest = Segment(MAX, -1, -1)
_range = Segment(MAX, -1, -1)
for i in range(n):
	(a, b) = map(int, input().split())
	if a < _range.l:
		_range.l = a
	if b > _range.r:
		_range.r = b
	if a <= longest.l and b >= longest.r:
		longest = Segment(a, b, i + 1)
if longest.l <= _range.l and longest.r >= _range.r:
	print(longest.idx)
else:
	print(-1)


n = int(input())
a = []
mx = 0
for i in range(n):
	pair = input().split()
	trip = (int(pair[0]), int(pair[1]), i)
	mx = max(mx, int(pair[1]))
	a.append(trip)
a.sort()
found = 0
for i in range(n):
	if found == 0 and a[i][0] <= a[0][0] and (a[i][1] >= mx):
		print(a[i][2] + 1)
		found = 1
if found == 0:
	print(-1)


n = int(input())
l = []
(x, y) = ([], [])
for i in range(n):
	d = list(map(int, input().split()))
	l.append(d)
	x.append(d[0])
	y.append(d[1])
m = min(x)
mm = max(y)
f = -1
for i in range(n):
	if l[i][0] == m and mm == l[i][1]:
		f = i + 1
		break
print(f)


n = l = r = minl = maxr = 0
number = 1
n = int(input(''))
(minl, maxr) = map(int, input().split())
for i in range(2, n + 1):
	(l, r) = map(int, input().split())
	if l <= minl and r >= maxr:
		number = i
	elif l < minl or r > maxr:
		number = -1
	minl = min(minl, l)
	maxr = max(maxr, r)
print(number)


t = int(input())
minimum = 10 ** 9
maximum = 1
L = []
for i in range(t):
	l = list(map(int, input().split()))
	L.append(l)
	if l[0] < minimum:
		minimum = l[0]
	if l[1] > maximum:
		maximum = l[1]
if [minimum, maximum] not in L:
	print(-1)
else:
	print(L.index([minimum, maximum]) + 1)


n = int(input())
p = []
(mi, ma) = (9999999999, -9999999999)
for _ in range(n):
	(a, b) = map(int, input().split())
	x = [a, b]
	p.append(x)
	if a < mi:
		mi = a
	if b > ma:
		ma = b
f = [mi, ma]
if f in p:
	print(p.index(f) + 1)
else:
	print(-1)


n = int(input())
maxi = 0
mini = float('inf')
d = []
c = -1
for i in range(n):
	(a, b) = map(int, input().split())
	mini = min(mini, a, b)
	maxi = max(maxi, a, b)
	d.append((a, b))
a = (mini, maxi)
for i in range(n):
	if d[i] == a:
		c = i + 1
print(c)


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	a.append(x)
	b.append(y)
mn = min(a)
mx = max(b)
count = 0
for (i, j) in zip(a, b):
	if i == mn and j == mx:
		print(count + 1)
		break
	count += 1
else:
	print(-1)


n = int(input())
a = []
count = 0
min = 1000000000
max = 0
for i in range(n):
	temp = list(map(int, input().split()))
	a.append(temp)
for i in range(0, n, 1):
	if a[i][0] < min:
		min = a[i][0]
	if a[i][1] > max:
		max = a[i][1]
for j in range(0, n, 1):
	if a[j][0] == min and a[j][1] == max:
		print(j + 1)
		exit()
print(-1)


def gint():
	return int(input())

def gint_arr():
	return list(map(int, input().split()))

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
n = gint()
seg = []
max_right = -INF
for i in range(1, n + 1):
	inp = gint_arr()
	max_right = max(max_right, inp[1])
	seg.append(tuple(inp + [i]))
seg.sort()
i = 1
while i < n and seg[i][0] == seg[0][0]:
	i += 1
i -= 1
print(seg[i][2] if max_right <= seg[i][1] else -1)


n = int(input())
segments = []
lowers = []
uppers = []
for i in range(n):
	segments.append(list(map(int, input().split())))
	lowers.append(segments[i][0])
	uppers.append(segments[i][1])
minimum = min(lowers)
maximum = max(uppers)
result = -1
for i in range(n):
	if segments[i][0] <= minimum and segments[i][1] >= maximum:
		result = i + 1
print(result)


def main():
	n = int(input())
	segment = []
	for i in range(n):
		(first, last) = map(int, input().split())
		segment.append((first, last, i + 1))
	segment.sort(key=lambda seg: seg[0])
	Cover_segment = set()
	start = segment[0][0]
	for i in range(n):
		if segment[i][0] == start:
			Cover_segment.add(segment[i][2])
		else:
			break
	segment.sort(key=lambda seg: seg[1], reverse=True)
	end = segment[0][1]
	for i in range(n):
		if segment[i][1] == end:
			if segment[i][2] in Cover_segment:
				print(segment[i][2])
				break
		else:
			print(-1)
			break
main()


def check_cover(_l, _r, _n):
	(min_left, max_right) = (_l[0], _r[0])
	pos = 0
	for i in range(1, n):
		if _l[i] < min_left:
			min_left = _l[i]
			if _r[i] >= max_right:
				pos = i
				max_right = _r[i]
			else:
				pos = -2
		elif _r[i] > max_right:
			max_right = _r[i]
			if _l[i] <= min_left:
				pos = i
				min_left = _l[i]
			else:
				pos = -2
		elif _l[i] == min_left and _r[i] == max_right:
			pos = i
	return pos + 1
n = int(input())
(l, r) = ([], [])
for i in range(n):
	(li, ri) = map(int, input().split())
	l.append(li)
	r.append(ri)
print(check_cover(l, r, n))


n = int(input())
size = n
pos = 1
j = input().split()
(a, b) = (int(j[0]), int(j[1]))
while n > 1:
	i = input().split()
	(x, y) = (int(i[0]), int(i[1]))
	if x <= a and y >= b:
		(a, b) = (x, y)
		pos = size - n + 2
	elif x >= a and y <= b:
		pass
	else:
		pos = -1
	if x < a:
		a = x
	if y > b:
		b = y
	n -= 1
print(pos)


n = int(input())
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	l += [(x, y)]
(rm, lm) = zip(*l)
(a, b) = (min(rm), max(lm))
print('-1' if (a, b) not in l else l.index((a, b)) + 1)


n = int(input())
(ar, br) = ([], [])
for i in range(n):
	(a, b) = map(int, input().split())
	ar.append(a)
	br.append(b)
mi = min(ar)
ma = max(br)
ind = [index for (index, element) in enumerate(ar) if element == mi]
for k in ind:
	if br[k] == ma:
		print(k + 1)
		exit()
print(-1)


n = int(input())
l1 = []
s = set()
for _ in range(n):
	(a, b) = map(int, input().split())
	l = [a, b]
	s.add(a)
	s.add(b)
	l1.append(l)
mx = max(s)
mn = min(s)
for i in range(len(l1)):
	if l1[i][0] <= mn and l1[i][1] >= mx:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
left = [0] * n
right = [0] * n
for i in range(n):
	(left[i], right[i]) = map(int, input().split())
minLeft = min(left)
maxRight = max(right)
ans = -1
for i in range(n):
	if left[i] == minLeft and right[i] == maxRight:
		ans = i + 1
		break
print(ans)


n = int(input())
(l, r) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
(minX, maxY) = (1000000000, 0)
ans = -1
for i in range(n):
	if l[i] <= minX and r[i] >= maxY:
		minX = l[i]
		maxY = r[i]
		ans = i + 1
if minX <= min(l) and maxY >= max(r):
	print(ans)
else:
	print(-1)


n = int(input())
arr = list()
min = 10 ** 9
max = 0
for a in range(n):
	arr.append(list(map(int, input().split())))
	if arr[a][0] < min:
		min = arr[a][0]
	if arr[a][1] > max:
		max = arr[a][1]
try:
	r = arr.index([min, max])
	print(r + 1)
except:
	print(-1)


n = int(input())
p = -1
l_array = []
r_array = []
for i in range(n):
	(l, r) = map(int, input().split())
	l_array.append(l)
	r_array.append(r)
x = max(r_array)
y = min(l_array)
for i in range(n):
	if l_array[i] == y and r_array[i] == x:
		p = i + 1
print(p)


def mi():
	return map(int, input().split())
n = int(input())
a = [0] * n
x1 = [0] * n
x2 = [0] * n
for i in range(n):
	(t1, t2) = mi()
	a[i] = [t1, t2]
	x1[i] = t1
	x2[i] = t2
n1 = min(x1)
n2 = max(x2)
for i in range(n):
	if a[i][0] <= n1 and a[i][1] >= n2:
		print(i + 1)
		exit(0)
print(-1)


n = int(input())
(a, b) = (float('inf'), 0)
l = []
for i in range(n):
	(n, m) = map(int, input().split())
	if n < a:
		a = n
	if m > b:
		b = m
	l.append([n, m])
if [a, b] in l:
	print(l.index([a, b]) + 1)
else:
	print(-1)


def segment_covered(n, segments):
	mini = ''
	maxi = ''
	ans = 0
	for n in range(len(segments)):
		if mini == '' and maxi == '':
			mini = segments[n][0]
			maxi = segments[n][1]
			ans = n + 1
		elif segments[n][0] > mini:
			if segments[n][1] > maxi:
				maxi = segments[n][1]
				ans = 0
		elif segments[n][0] < mini:
			mini = segments[n][0]
			if segments[n][1] >= maxi:
				ans = n + 1
				maxi = segments[n][1]
			else:
				ans = 0
		elif segments[n][0] == mini:
			if segments[n][1] >= maxi:
				maxi = segments[n][1]
				ans = n + 1
	if ans == 0:
		return -1
	else:
		return ans
n = int(input())
segments = []
for x in range(n):
	q = list(map(int, input().split()))
	segments.append(q)
print(segment_covered(n, segments))


n = int(input())
segments = [[int(i) for i in input().split()] for j in range(n)]
left = segments[0][0]
right = segments[0][1]
for seg in segments:
	if seg[0] < left:
		left = seg[0]
	if seg[1] > right:
		right = seg[1]
for i in range(n):
	if segments[i][0] <= left and segments[i][1] >= right:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
(w, h) = (2, n)
a = [[0 for x in range(w)] for y in range(h)]
for i in range(n):
	(a[i][0], a[i][1]) = map(int, input().split(' '))
low = 1000000000
high = 0
for i in range(n):
	if a[i][0] < low:
		low = a[i][0]
	if a[i][1] > high:
		high = a[i][1]
found = False
for i in range(n):
	if a[i][0] <= low and a[i][1] >= high:
		print(i + 1)
		found = True
if not found:
	print(-1)


n = int(input())
mat = []
for i in range(n):
	l = list(map(int, input().split()))
	mat.append(l)
mini = 10 ** 10
maxi = 0
for i in range(n):
	mini = min(mini, mat[i][0])
	maxi = max(maxi, mat[i][1])
flag = 0
for i in range(n):
	if mat[i][0] == mini and mat[i][1] == maxi:
		flag = 1
		p = i + 1
		break
if flag == 0:
	print(-1)
else:
	print(p)


number_of_segments = int(input())
segments = []
min_left = 1000000001
max_right = 0
index_of_largest_segment = -1
for index in range(number_of_segments):
	(left, right) = map(int, input().split())
	if left < min_left:
		min_left = left
	if right > max_right:
		max_right = right
	segments.append([left, right])
for (index, segment) in enumerate(segments):
	if segment[0] == min_left and segment[1] == max_right:
		index_of_largest_segment = index + 1
print(index_of_largest_segment)


n = int(input())
(min_num, max_num) = map(int, input().split())
(min_i, max_i) = (1, 1)
i_found = False
i_chosen = 1
for i in range(n - 1):
	(left_i, right_i) = map(int, input().split())
	if left_i < min_num:
		if right_i >= max_num:
			i_chosen = i + 2
			min_num = left_i
			max_num = right_i
			min_i = i + 2
			max_i = i + 2
		else:
			min_num = left_i
			min_i = i + 2
	elif left_i == min_num:
		if right_i >= max_num:
			i_chosen = i + 2
			min_num = left_i
			max_num = right_i
			min_i = i + 2
			max_i = i + 2
		else:
			continue
	elif right_i > max_num:
		max_num = right_i
		max_i = i + 2
	else:
		continue
if min_i == max_i:
	print(min_i)
else:
	print(-1)


n = int(input())
s = [[*map(int, input().split())] for _ in ' ' * n]
s_ = list(zip(*s))
x = min(s_[0])
y = max(s_[1])
if [x, y] in s:
	print(s.index([x, y]) + 1)
else:
	print(-1)


n = int(input())
A = tuple([tuple(map(int, input().split())) for i in range(n)])
L = [l for (l, r) in A]
R = [r for (l, r) in A]
L = min(L)
R = max(R)
p = (L, R)
if p in A:
	print(A.index(p) + 1)
else:
	print(-1)


n = int(input())
(a, b) = (10 ** 9, -1)
l = []
for _ in range(n):
	(x, y) = map(int, input().split())
	a = min(a, x)
	b = max(b, y)
	l.append((x, y))
try:
	print(l.index((a, b)) + 1)
except ValueError:
	print(-1)


n = int(input())
ls = []
for _ in range(n):
	ls.append(list(map(int, input().split(' '))))
a = 10 ** 9
b = 0
for i in range(n):
	a = min(a, ls[i][0])
	b = max(b, ls[i][1])
ans = [a, b]
if ans in ls:
	print(ls.index(ans) + 1)
else:
	print(-1)


def program():
	num = -1
	R = []
	L = []
	n = int(eval(input()))
	for i in range(n):
		(l, r) = list(map(int, input().split()))
		R.append(r)
		L.append(l)
	MAXR = max(R)
	MINL = min(L)
	for i in range(n):
		if R[i] == MAXR and L[i] == MINL:
			print(i + 1)
			return
	print(num)
program()


n = int(input())
ans = []
mini = 10 ** 19
maxi = -10 ** 19
for i in range(n):
	(l, r) = map(int, input().split())
	ans.append([l, r, i + 1])
	if l <= mini:
		mini = l
	if r >= maxi:
		maxi = r
res = -1
for i in range(n):
	l = ans[i][0]
	r = ans[i][1]
	if l <= mini and r >= maxi:
		res = ans[i][2]
print(res)


def main_dumb():
	quant_of_segments = int(input())
	sgmnts = [tuple(map(int, input().split())) for k in range(quant_of_segments)]
	for k in range(quant_of_segments):
		if all([s[0] >= sgmnts[k][0] and s[1] <= sgmnts[k][1] for s in sgmnts]):
			print(k + 1)
			break
	else:
		print(-1)

def main():
	quant_of_segments = int(input())
	sgmnts = [tuple(list(map(int, input().split())) + [k + 1]) for k in range(quant_of_segments)]
	sgmnts.sort(key=lambda x: x[0])
	sgmnts.sort(reverse=True, key=lambda x: x[1])
	res = sgmnts[0]
	if all([s[0] >= res[0] and s[1] <= res[1] for s in sgmnts[1:]]):
		print(res[2])
	else:
		print(-1)
main()


def bigSegment(n, li):
	import sys
	min_ = sys.maxsize
	max_ = -99
	max_index = 0
	min_index = 0
	for j in range(2):
		for i in range(n):
			if j == 0:
				if li[i][0] <= min_:
					min_ = li[i][0]
			elif li[i][1] >= max_:
				max_ = li[i][1]
	for i in range(n):
		if li[i][0] == min_ and li[i][1] == max_:
			return i + 1
	else:
		return -1
n = int(input())
li = []
for i in range(n):
	a = [int(x) for x in input().split()]
	li.append(a)
print(bigSegment(n, li))


n = int(input())
array = []
min_left = 10 ** 9
max_right = 1
for i in range(0, n):
	(x, y) = map(int, input().split())
	min_left = min(x, min_left)
	max_right = max(y, max_right)
	array.append([x, y])
if [min_left, max_right] in array:
	print(array.index([min_left, max_right]) + 1)
else:
	print('-1')


n = int(input())
maxn = 0
minn = 100000000000.0
dicta = {}
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if b > maxn:
		maxn = b
	if a < minn:
		minn = a
	dicta[str(a) + str(b)] = i + 1
ires = dicta.get(str(minn) + str(maxn))
if ires != None:
	print(ires)
else:
	print(-1)


n = int(input())
segments = []
minl = 10 ** 9
maxr = 1
for i in range(n):
	(a, b) = map(int, input().split())
	segments.append((a, b))
	if a < minl:
		minl = a
	if b > maxr:
		maxr = b
if (minl, maxr) in segments:
	print(segments.index((minl, maxr)) + 1)
else:
	print(-1)


n_seg = int(input())
Segments = []
for _ in range(n_seg):
	Segments.append(list(map(int, input().rstrip().split())))
Min = min([Segments[i][0] for i in range(n_seg)])
Max = max([Segments[i][1] for i in range(n_seg)])
if [Min, Max] in Segments:
	print(Segments.index([Min, Max]) + 1)
else:
	print(-1)


class Segment:

	def __init__(self, start, end):
		self.start = start
		self.end = end
number_of_segments = int(input())
min_left = 10 ** 9 + 1
max_right = 0
segments = []
for index in range(number_of_segments):
	(left, right) = map(int, input().split())
	segment = Segment(left, right)
	if min_left > left:
		min_left = left
	if max_right < right:
		max_right = right
	segments.append([left, right])
result = -1
for index in range(number_of_segments):
	if segments[index][0] == min_left and segments[index][1] == max_right:
		result = index + 1
		break
print(result)


segment_arr = []
size = int(input())
max_right = 0
min_left = 1000000000
index = 0
for i in range(size):
	(li, ri) = map(int, input().split())
	if li <= min_left and ri >= max_right:
		index = i + 1
	elif li < min_left or ri > max_right:
		index = -1
	max_right = max(ri, max_right)
	min_left = min(li, min_left)
print(index)


l = []
p = []
q = []
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	l.append((m, n))
	p.append(m)
	q.append(n)
	t -= 1
m = min(p)
q = max(q)
x = 1
r = True
for (i, j) in l:
	if i == m and j == q:
		print(x)
		r = False
		break
	x += 1
if r:
	print('-1')


import math, sys
from collections import Counter

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

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
n = ii()
a = []
b = []
for _ in range(n):
	(l, r) = li()
	a.append(l)
	b.append(r)
x = min(a)
y = max(b)
flag = 0
for i in range(len(a)):
	if a[i] == x and y == b[i]:
		flag = 1
		print(i + 1)
		break
if flag == 0:
	print(-1)


a = sorted([[*map(int, s.split()), i] for (i, s) in enumerate([*open(0)][1:])], key=lambda x: (x[0], -x[1]))
print([a[0][2] + 1, -1][any((a[0][1] < x[1] for x in a))])


tc = int(input())
(min_x, max_y) = (10 ** 9 + 1, 0)
arr = []
for _ in range(tc):
	(x, y) = map(int, input().split())
	if x < min_x:
		min_x = x
	if y > max_y:
		max_y = y
	arr.append((x, y))
i = 0
f = 1
for x in arr:
	if x[0] == min_x and x[1] == max_y:
		print(i + 1)
		f = 0
	i += 1
if f:
	print(-1)


n = int(input())
(lmin, rmax) = map(int, input().split())
lset = set()
rset = set()
lset.add(1)
rset.add(1)
for i in range(2, n + 1):
	(l, r) = map(int, input().split())
	if l == lmin:
		lset.add(i)
	elif l < lmin:
		lmin = l
		lset.clear()
		lset.add(i)
	if r == rmax:
		rset.add(i)
	elif r > rmax:
		rmax = r
		rset.clear()
		rset.add(i)
inter = lset & rset
if len(inter) == 0:
	print(-1)
else:
	print(inter.pop())


n = int(input())
list_segment = []
list_min = []
list_max = []
for _ in range(n):
	segment = list(map(int, input().split()))
	list_min.append(segment[0])
	list_max.append(segment[1])
	list_segment.append(segment)
min = min(list_min)
max = max(list_max)
count = 1
for s in list_segment:
	if (s[0] == min) & (s[1] == max):
		print(count)
		exit()
	else:
		count += 1
print(-1)


n = int(input())
mi = 9999999999
ma = -1
j = -1
mi1 = 9999999999
ma1 = -1
for i in range(n):
	(a, b) = map(int, input().split())
	if a <= mi and b >= ma:
		mi = a
		ma = b
		j = i + 1
	elif a <= mi and b < ma:
		mi1 = a
	elif a > mi and b >= ma:
		ma1 = b
if ma1 > ma or mi1 < mi or j == -1:
	print('-1')
else:
	print(j)


n = int(input())
dic = {}
points = []
d = 0
c = 1000000000000000
for i in range(n):
	(a, b) = map(int, input().split())
	points.append((a, b))
	c = min(c, a)
	d = max(d, b)
	dic[a, b] = i + 1
points.sort()
boo = False
for i in points:
	if i[0] <= c and i[1] >= d:
		boo = True
		print(dic[i[0], i[1]])
		break
if not boo:
	print(-1)


n = int(input())
(lmin, rmax) = tuple(map(int, input().split()))
ans = 1
for i in range(2, n + 1):
	(l, r) = tuple(map(int, input().split()))
	if l <= lmin and r >= rmax:
		ans = i
	elif l < lmin or r > rmax:
		ans = -1
	lmin = min(l, lmin)
	rmax = max(r, rmax)
print(ans)


import math
n = int(input())
sega = []
segb = []
for i in range(n):
	(a, b) = map(int, input().split())
	sega.append(a)
	segb.append(b)
mina = min(sega)
maxb = max(segb)
seg = -1
for i in range(n):
	if sega[i] == mina and segb[i] == maxb:
		seg = i + 1
		break
print(seg)


def solve(lines):
	if not lines:
		return -1
	(l, r) = (lines[0][0], lines[0][1])
	res = 1
	for i in range(1, len(lines)):
		left = lines[i][0]
		right = lines[i][1]
		if left <= l and r <= right:
			res = i + 1
		elif left < l or r < right:
			res = -1
		l = min(left, l)
		r = max(right, r)
	return res
n = int(input())
lines = []
for i in range(n):
	nums = list(map(int, input().split()))
	lines.append(nums)
print(solve(lines))


n = int(input())
b = []
e = []
left = 10 ** 9
righ = 0
for _ in range(n):
	(sb, se) = map(int, input().split())
	if sb < left:
		left = sb
	if se > righ:
		righ = se
	b.append(sb)
	e.append(se)
cover = False
loc = n
for i in range(n):
	if b[i] <= left and e[i] >= righ:
		cover = True
		loc = min(i, loc) + 1
if cover:
	print(loc)
else:
	print('-1')


mi = 9999999999
ma = 0
arr2 = []
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	mi = min(mi, a)
	ma = max(ma, b)
	arr2.append((a, b))
if (mi, ma) in arr2:
	print(arr2.index((mi, ma)) + 1)
else:
	print(-1)


n = int(input())
a = 1000000000
b = 0
c = []
d = []
l = 0
for i in range(n):
	(auxa, auxb) = list(map(int, input().split(' ')))
	if auxa < a:
		a = auxa
	if auxb > b:
		b = auxb
	c.append(auxa)
	d.append(auxb)
	l += 1
for i in range(l):
	if c[i] == a and d[i] == b:
		print(i + 1)
		exit()
print(-1)


class line:

	def __init__(self, l, r):
		self.l = l
		self.r = r

	def cover(self, d2):
		if self.l <= d2.l <= d2.r <= self.r:
			return True
		else:
			return False
n = int(input())
arr = []
for i in range(n):
	(l, r) = map(int, input().split())
	temp = line(l, r)
	arr.append(temp)
co = arr[0]
for k in range(n):
	if arr[k].l <= co.l and arr[k].r >= co.r:
		co = arr[k]
		h = k
r = True
for f in range(n):
	if not co.cover(arr[f]):
		r = False
		break
if r:
	print(h + 1)
else:
	print(-1)


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	n = int(input())
	(mi, ma) = (10 ** 10, -1)
	l = []
	for i in range(n):
		(a, b) = map(int, input().split())
		mi = min(mi, a)
		ma = max(ma, b)
		l.append((a, b))
	(check, ind) = (False, 0)
	for (i, v) in enumerate(l):
		if check:
			break
		check |= v[0] <= mi and v[1] >= ma
		ind = i + 1
	print(ind if check else -1)
main()


import sys
f = sys.stdin
n = int(f.readline().strip())
(l, r) = ([], [])
for line in f:
	l.append(int(line.strip().split()[0]))
	r.append(int(line.strip().split()[1]))
ls = list(set(l))
rs = list(set(r))
ls.sort()
rs.sort(reverse=True)
ind = -1
for i in range(n):
	if l[i] <= ls[0] and r[i] >= rs[0]:
		ind = i + 1
print(ind)


segments = []
n = int(input())
for i in range(n):
	segments.append([int(x) for x in input().split()] + [i + 1])
max_r = max([s[1] for s in segments])
min_l = min([s[0] for s in segments])
flag = False
for (i, s) in enumerate(segments):
	if s[0] == min_l and s[1] == max_r:
		print(i + 1)
		flag = True
		break
if not flag:
	print(-1)


n = int(input())
a = []
mn = 1000000000.0
mx = -1000000000.0
for i in range(n):
	(l, r) = map(int, input().split())
	a.append([l, r])
	mn = min(l, mn)
	mx = max(r, mx)
for i in range(n):
	if a[i][0] == mn and a[i][1] == mx:
		print(i + 1)
		exit(0)
print(-1)


n = int(input())
mini = float('inf')
maxi = float('-inf')
segs = []
for _ in range(n):
	(a, b) = map(int, input().split())
	mini = min(a, mini)
	maxi = max(b, maxi)
	segs.append((a, b))
res = (mini, maxi)
if res in segs:
	print(segs.index(res) + 1)
else:
	print(-1)


n = int(input())
left = []
right = []
for i in range(n):
	a = list(map(int, input().split(' ')))
	left.append(a[0])
	right.append(a[1])
lmost = min(left)
rmost = max(right)
b = 0
for i in range(n):
	if left[i] == lmost and right[i] == rmost:
		print(i + 1)
		b = 1
		break
if b == 0:
	print(-1)


n = int(input())
l = []
r = []
for i in range(n):
	segment = list(map(int, input().split()))
	l.append(segment[0])
	r.append(segment[1])
left = min(l)
right = max(r)
res = -1
for i in range(n):
	if l[i] == left and r[i] == right:
		res = i + 1
print(res)


from math import inf
n = int(input())
lesl = inf
grr = 0
indl = -1
indr = -1
lar = []
rar = []
for i in range(n):
	iarr = list(map(int, input().split()))
	l = iarr[0]
	r = iarr[1]
	lar.append(l)
	rar.append(r)
	if l < lesl:
		lesl = l
		indl = i
	if r > grr:
		grr = r
		indr = i
flag = 0
for i in range(n):
	if lar[i] == lesl and rar[i] == grr:
		print(i + 1)
		flag = 1
		break
if flag == 0:
	print(-1)


n = int(input())
l = []
r = []
for _ in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
li = min(l)
ri = max(r)
flag = False
for i in range(n):
	if l[i] == li and r[i] == ri:
		print(i + 1)
		flag = True
		break
if not flag:
	print(-1)


n = int(input())
(tmax, tmin) = (1, 1000000000)
ans = 0
for i in range(n):
	c = 0
	(l, r) = map(int, input().split())
	if r >= tmax and l <= tmin:
		(tmax, tmin) = (r, l)
		c = 1
	elif r > tmax:
		tmax = r
		c = -1
	elif l < tmin:
		tmin = l
		c = -1
	if c == 1:
		ans = i + 1
	elif c == -1:
		ans = -1
print(ans)


n = int(input())
mx = -1
mn = 1000000001
for k in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a <= mn and b >= mx:
		mn = a
		mx = b
		i = k + 1
	elif a < mn or b > mx:
		if a < mn:
			mn = a
			i = -1
		elif b > mx:
			mx = b
			i = -1
print(i)


try:
	n = int(input())
	l = [0] * n
	g = [0] * n
	ind = 0
	for i in range(0, n):
		(l[i], g[i]) = map(int, input().split())
		if i == 0:
			k = l[i]
			j = g[i]
		elif l[i] <= k and g[i] >= j:
			k = l[i]
			j = g[i]
			ind = i
	if k == min(l) and j == max(g):
		if ind > 0:
			print(ind + 1)
		else:
			print(1)
	else:
		print(-1)
except Exception:
	pass


n = int(input())
a = []
b = []
c = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(l)
	b.append(r)
	c.append((l, r))
res1 = min(a)
res2 = max(b)
res3 = (res1, res2)
if res3 not in c:
	print('-1')
else:
	print(c.index(res3) + 1)


import sys
n = int(input())
mini = 0
maxi = 0
mn = sys.maxsize
mx = 0
for i in range(1, n + 1):
	(x, y) = map(int, input().split())
	if x <= mn and y >= mx:
		mn = x
		mini = i
		mx = y
		maxi = i
	if y > mx:
		mx = y
		maxi = i
	if x < mn:
		mn = x
		mini = i
if mini == maxi:
	print(mini)
else:
	print(-1)


n = int(input())
l1 = []
l2 = []
for i in range(0, n):
	(x, y) = map(int, input().split())
	l1.append((x, -1 * y, i + 1))
	l2.append((y, -1 * x))
l1.sort()
l2.sort()
if -1 * l1[0][1] == l2[n - 1][0]:
	print(l1[0][2])
else:
	print(-1)


n = int(input())
a = []
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
	l.append(x)
	r.append(y)
if [min(l), max(r)] in a:
	print(a.index([min(l), max(r)]) + 1)
else:
	print(-1)


n = int(input())
arr = []
for i in range(n):
	(a, b) = [int(j) for j in input().split()]
	arr.append((a, a - b, -i))
	arr.append((b, b - a, i))
arr.sort()
if -arr[0][2] == arr[-1][2]:
	print(arr[-1][2] + 1)
else:
	print(-1)


n = int(input())
l = []
(mi, ma) = (11 ** 11, 0)
for _ in range(n):
	(x, y) = map(int, input().split())
	if x < mi:
		mi = x
	if y > ma:
		ma = y
	l += [(x, y)]
if (mi, ma) in l:
	print(l.index((mi, ma)) + 1)
else:
	print(-1)


n = int(input())
a = []
b = -1
mn = 10000000000
mx = 0
for i in range(n):
	a.append(list(map(int, input().split(' '))))
	mn = min(mn, a[i][0])
	mx = max(mx, a[i][1])
	if b == -1 or (a[b][0] >= a[i][0] and a[b][1] <= a[i][1]):
		b = i
if a[b][0] <= mn and a[b][1] >= mx:
	print(b + 1)
else:
	print(-1)


n = int(input())
sa = []
sb = []
for i in range(n):
	(a, b) = map(int, input().split())
	sa.append(a)
	sb.append(b)
mi = 10 ** 9
ma = -1
f = 0
for i in range(n):
	if sa[i] < mi:
		mi = sa[i]
	if sb[i] > ma:
		ma = sb[i]
for i in range(n):
	if sa[i] == mi and sb[i] == ma:
		f = 1
		break
if f:
	print(i + 1)
else:
	print(-1)


import sys, threading, os.path
import collections, heapq, math, bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('input.txt'):
		input = open('input.txt', 'r')
	else:
		input = sys.stdin
	n = int(input.readline())
	segs = []
	for i in range(n):
		segs.append(list(map(int, input.readline().split())))
	(nummax, summax) = (0, 0)
	for i in range(n):
		if segs[i][1] - segs[i][0] > summax:
			nummax = i
			summax = segs[i][1] - segs[i][0]
	ok = True
	for i in range(n):
		if segs[i][0] < segs[nummax][0] or segs[i][1] > segs[nummax][1]:
			ok = False
			break
	if ok:
		output = nummax + 1
	else:
		output = -1
	if os.path.exists('output.txt'):
		open('output.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


from functools import reduce
from collections import Counter
import time
import datetime

def time_t():
	print('Current date and time: ', datetime.datetime.now())
	print('Current year: ', datetime.date.today().strftime('%Y'))
	print('Month of year: ', datetime.date.today().strftime('%B'))
	print('Week number of the year: ', datetime.date.today().strftime('%W'))
	print('Weekday of the week: ', datetime.date.today().strftime('%w'))
	print('Day of year: ', datetime.date.today().strftime('%j'))
	print('Day of the month : ', datetime.date.today().strftime('%d'))
	print('Day of week: ', datetime.date.today().strftime('%A'))

def ip():
	return int(input())

def sip():
	return input()

def mip():
	return map(int, input().split())

def mips():
	return map(str, input().split())

def lip():
	return list(map(int, input().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)
t = ip()
lst = []
x = 10000000000
y = 0
for i in range(t):
	a = lip()
	lst.append(a)
	x = min(x, a[0])
	y = max(y, a[1])
if [x, y] in lst:
	print(lst.index([x, y]) + 1)
else:
	print(-1)


n = int(input())
l = []
r = []
for i in range(n):
	(s, e) = map(int, input().split())
	l.append(s)
	r.append(e)
mn = l[0]
mx = r[0]
for i in range(n):
	if l[i] < mn:
		mn = l[i]
	if r[i] > mx:
		mx = r[i]
flag = 1
p = 0
for i in range(n):
	if l[i] <= mn and r[i] >= mx:
		p = i + 1
		flag = 0
if flag == 0:
	print(p)
else:
	print(-1)


n = int(input())
mx = float('inf')
mxs = set()
my = -1
mys = set()
for i in range(n):
	(x, y) = map(int, input().split())
	if x < mx:
		mx = x
		mxs = {i + 1}
	elif x == mx:
		mxs.add(i + 1)
	if y > my:
		my = y
		mys = {i + 1}
	elif y == my:
		mys.add(i + 1)
if mxs & mys:
	print(list(mxs & mys)[0])
else:
	print(-1)


n = int(input())
l = []
l_w = []
for i in range(0, n):
	s = input()
	(a, b) = map(int, s.split(' '))
	l.append([a, b])
	l_w.append(a)
	l_w.append(b)
l_w.sort()
test = [l_w[0], l_w[len(l_w) - 1]]
if test in l:
	print(l.index(test) + 1)
else:
	print(-1)


from collections import Counter

def solve():
	n = int(input())
	l = []
	for _ in range(n):
		l.append(list(map(int, input().split())))
	mn = min(l, key=lambda x: x[0])[0]
	mx = max(l, key=lambda x: x[1])[1]
	ans = -1
	for i in range(n):
		if l[i][0] == mn and l[i][1] == mx:
			print(i + 1)
			return
	print(-1)
solve()


num_segments = int(input())
biggest_segment = 1
(left_margin, right_margin) = map(int, input().split())
for pos in range(2, num_segments + 1):
	(segment_left, segment_right) = map(int, input().split())
	if segment_left <= left_margin and segment_right >= right_margin:
		biggest_segment = pos
		left_margin = segment_left
		right_margin = segment_right
	elif segment_left < left_margin and segment_right < right_margin or (segment_left > left_margin and segment_right > right_margin):
		biggest_segment = -1
		left_margin = min(left_margin, segment_left)
		right_margin = max(right_margin, segment_right)
print(biggest_segment)


n = int(input())
sett = []
mini = float('inf')
maxi = -float('inf')
for _ in range(n):
	(x, y) = [int(x) for x in input().split()]
	mini = min(x, mini)
	maxi = max(y, maxi)
	sett.append((x, y))
if (mini, maxi) in sett:
	print(sett.index((mini, maxi)) + 1)
else:
	print(-1)


class lines:

	def __init__(self, l, r):
		self.r = r
		self.l = l
n = int(input())
arr = []
for i in range(n):
	(l, r) = map(int, input().split())
	arr.append(lines(l, r))
index = -1
lc = 10 ** 9
rc = 0
for i in range(0, n):
	if arr[i].l < lc:
		lc = arr[i].l
for i in range(0, n):
	if arr[i].r > rc:
		rc = arr[i].r
for i in range(n):
	if arr[i].l == lc and arr[i].r == rc:
		index = i + 1
		break
print(index)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
mod = 10 ** 9 + 7
n = I()
x = [0] * n
y = [0] * n
xmin = math.inf
ymax = -math.inf
for i in range(n):
	(x[i], y[i]) = R()
	xmin = min(x[i], xmin)
	ymax = max(ymax, y[i])
for i in range(n):
	if x[i] == xmin and y[i] == ymax:
		print(i + 1)
		exit()
print('-1')


n = int(input())
segments = [list(map(int, (input() + ' ' + str(i + 1)).split())) for i in range(n)]
ssegments = sorted(segments, key=lambda seg: seg[1], reverse=True)
ssegments = sorted(ssegments, key=lambda seg: seg[0])
good = True
for s in ssegments:
	if ssegments[0][0] > s[0] or ssegments[0][1] < s[1]:
		good = False
		break
if good:
	print(ssegments[0][2])
else:
	print(-1)


n = int(input())
ilines = []
minl = 10 ** 9
maxr = 0
for j in range(n):
	(l, r) = list(map(int, input().split()))
	if l < minl:
		minl = l
	if r > maxr:
		maxr = r
	ilines.append((l, r))
index = -1
for i in range(n):
	if ilines[i][0] == minl and ilines[i][1] == maxr:
		index = i + 1
		break
print(index)


n = int(input())
x = []
y = []
z = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
xmin = min(x)
ymax = max(y)
for i in range(n):
	if x[i] == xmin and y[i] == ymax:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
minL = min(l)
maxR = max(r)
flag = -1
for i in range(n):
	if l[i] == minL and r[i] == maxR:
		print(i + 1)
		flag = 0
		break
if flag == -1:
	print(-1)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
mi = min(a)
ma = max(b)
count = 0
for i in range(n):
	if a[i] == mi and b[i] == ma:
		count = 1
		print(i + 1)
		break
if count == 0:
	print(-1)


n = int(input())
l = 1000000000.0 + 10
r = 0
line = []
for i in range(n):
	inp = input().split(' ')
	line.append([int(inp[0]), int(inp[1])])
	if line[i][0] < l:
		l = line[i][0]
	if line[i][1] > r:
		r = line[i][1]
cover = -1
for i in range(n):
	if line[i][0] == l and line[i][1] == r:
		cover = i + 1
		break
print(cover)


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
t = min(x)
v = max(y)
s = [(x[i], y[i]) for i in range(n)]
if (t, v) in s:
	print(s.index((t, v)) + 1)
else:
	print(-1)


import collections, math, itertools, bisect, heapq, copy

class Solution:

	def solve(self):
		n = int(input())
		left = float('inf')
		right = float('-inf')
		res = False
		ans = -1
		for i in range(n):
			(start, end) = list(map(int, input().rstrip().split()))
			if start <= left and end >= right:
				res = True
				ans = i + 1
				left = start
				right = end
			elif (start >= left and start <= right) and (end <= right and end >= left):
				continue
			else:
				res = False
				left = min(start, left)
				right = max(end, right)
		if res:
			print(ans)
		else:
			print(-1)
solution = Solution()
solution.solve()


n = int(input())
segments = []
leftest = 10 ** 9
rightest = -1
longest = -1
for i in range(n):
	(li, ri) = map(int, input().split(' '))
	leftest = min(li, leftest)
	rightest = max(ri, rightest)
	if li == leftest and ri == rightest:
		longest = (li, ri, i + 1)
if longest[0] == leftest and longest[1] == rightest:
	print(longest[2])
else:
	print(-1)


class segment:

	def __init__(self, l, r):
		self.L = l
		self.R = r
n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	b = segment(l, r)
	a.append(b)
inf = 1000000009
maxi = -inf
mini = inf
for i in a:
	if mini > i.L:
		mini = i.L
	if maxi < i.R:
		maxi = i.R
res = -1
for i in range(1, n + 1):
	if mini == a[i - 1].L and maxi == a[i - 1].R:
		res = i
print(res)


n = int(input())
intervals = []
for i in range(n):
	intervals.append(list(map(int, input().split())))

def main():
	ls = []
	rs = []
	for i in intervals:
		ls.append(i[0])
		rs.append(i[1])
	min_l = min(ls)
	max_r = max(rs)
	for i in intervals:
		if i == [min_l, max_r]:
			print(intervals.index(i) + 1)
			return
	print(-1)
main()


n = int(input())
arr = []
(minnl, maxxr) = (float('inf'), -float('inf'))
for _ in range(n):
	(l, r) = map(int, input().split())
	arr.append([l, r])
	minnl = min(l, minnl)
	maxxr = max(r, maxxr)
try:
	print(arr.index([minnl, maxxr]) + 1)
except:
	print(-1)


n = int(input())
arr = []
ans = -1
x = 0
y = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	if len(arr) == 0:
		arr.append(a)
		arr.append(b)
	elif a <= arr[0] and b >= arr[1]:
		arr[0] = a
		arr[1] = b
		x = i
		y = i
	elif b > arr[1]:
		arr[1] = b
		y = i
	elif a < arr[0]:
		arr[0] = a
		x = i
if n == 1:
	print(1)
elif x == y and arr[0] != arr[1]:
	print(x + 1)
else:
	print(-1)


import math
n = int(input())
l = math.inf
r = -math.inf
a = []
for _ in range(n):
	(x, y) = map(int, input().split())
	if x < l:
		l = x
	if y > r:
		r = y
	a.append((x, y))
flag = True
for i in range(n):
	if a[i][0] == l and a[i][1] == r:
		break
else:
	flag = False
	print(-1)
if flag:
	print(i + 1)


l = []
for _ in range(int(input())):
	l.append(list(map(int, input().split())))
mn = min((l[i][0] for i in range(len(l))))
mx = max((l[j][1] for j in range(len(l))))
if [mn, mx] in l:
	print(l.index([mn, mx]) + 1)
else:
	print(-1)


n = int(input())
d = {}
min1 = float('inf')
max1 = float('-inf')
for i in range(n):
	(l, r) = map(int, input().split())
	d[l, r] = i + 1
	min1 = min(l, min1)
	max1 = max(r, max1)
if (min1, max1) in d:
	print(d[min1, max1])
else:
	print(-1)


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
n = ii()
segments = []
for i in range(n):
	segments.append(li())
segments_copy = segments.copy()
segments_copy.sort()
t = segments_copy[0]
pos = 0
for i in range(1, n):
	if segments_copy[i][0] == t[0]:
		t = segments_copy[i]
	else:
		pos = i
		break
for i in range(pos, n):
	if segments_copy[i][1] > t[1]:
		exit(print(-1))
print(segments.index(t) + 1)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
mina = min(a)
maxb = max(b)
ans = -1
for i in range(n):
	if a[i] == mina and b[i] == maxb:
		ans = i + 1
print(ans)


ans = 0
a = []
b = []
mn = 1000000000
mx = -1
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	mn = min(mn, x)
	b.append(y)
	mx = max(mx, y)
for i in range(n):
	if a[i] == mn and b[i] == mx:
		print(i + 1)
		break
else:
	print(-1)


n = int(input())
segments = []
minL = pow(10, 10)
maxR = -1
for i in range(n):
	(l, r) = map(int, input().split())
	segments.append([l, r])
	minL = min(l, minL)
	maxR = max(r, maxR)
for i in range(len(segments)):
	if segments[i][0] == minL and segments[i][1] == maxR:
		print(i + 1)
		exit()
print(-1)


def calculate_number_cover_segments(segments):
	second_elements = [segments[i][1] for i in range(len(segments))]
	first_elements = [segments[i][0] for i in range(len(segments))]
	max_ = max(second_elements)
	min_ = min(first_elements)
	result = [i + 1 for i in range(len(segments)) if second_elements[i] == max_ and first_elements[i] == min_]
	return result[0] if result else -1
n = int(input())
segments = [list(map(int, input().split())) for _ in range(n)]
print(calculate_number_cover_segments(segments))


a = []
for i in range(int(input())):
	a.append(list(map(int, input().split())) + [i])
b = sorted(a)
i = 0
l = min([x[0] for x in a])
r = max([x[1] for x in a])
for x in b:
	if x[0] == b[0][0]:
		i = x[2]
print(i + 1 if a[i][0] == l and a[i][1] == r else -1)


def inp():
	return map(int, input().split())
n = int(input())
l = list()
l.extend(100000 * [0])
r = list()
r.extend(100000 * [0])
idxl = 0
idxr = 0
minl = 1000000001
maxr = 0
for i in range(n):
	(l[i], r[i]) = inp()
	if l[i] < minl:
		minl = l[i]
		idxl = i
	if r[i] > maxr:
		maxr = r[i]
		idxr = i
for i in range(n):
	if (l[i] == minl) & (r[i] == maxr):
		print(i + 1)
		exit()
print(-1)


def big_segment(left, right):
	low = min(left)
	up = max(right)
	for i in range(len(left)):
		if left[i] == low and right[i] == up:
			return i + 1
	return -1
n = int(input())
l = []
r = []
for i in range(n):
	s = [int(x) for x in input().split()]
	l.append(s[0])
	r.append(s[1])
print(big_segment(l, r))


n = int(input())
x = [0] * n
y = [0] * n
for i in range(0, n):
	(x[i], y[i]) = input().split()
	(x[i], y[i]) = (int(x[i]), int(y[i]))
minx = x[0]
maxy = y[0]
minxIndices = []
maxyIndices = []
for i in range(0, n):
	if minx > x[i]:
		minx = x[i]
		minxIndices = []
		minxIndices.append(i)
	elif minx == x[i]:
		minxIndices.append(i)
	if maxy < y[i]:
		maxy = y[i]
		maxyIndices = []
		maxyIndices.append(i)
	elif maxy == y[i]:
		maxyIndices.append(i)
answer = list(set(minxIndices) & set(maxyIndices))
if len(answer) == 0:
	print('-1')
else:
	print(int(answer[0]) + 1)


N = int(input())
A = []
for n in range(N):
	(l, r) = map(int, input().split())
	A.append((-(r - l), l, r, n + 1))
A.sort()
valid = True
for (_, l, r, id) in A[1:]:
	if l < A[0][1] or r > A[0][2]:
		valid = False
		break
print(A[0][3] if valid else -1)


n = int(input())
l = []
a = []
b = []
for i in range(n):
	l.append(list(map(int, input().split())))
max_b = max((l[i][1] for i in range(n)))
min_b = min((l[i][0] for i in range(n)))
for i in range(n):
	if l[i][1] == max_b and l[i][0] == min_b:
		k = i + 1
		break
	else:
		k = -1
print(k)


def main():
	n = int(input())
	segment = []
	for i in range(n):
		(first, last) = map(int, input().split())
		segment.append((first, last, i + 1))
	segment.sort(key=lambda seg: seg[0])
	Cover_segment = set()
	start = segment[0][0]
	for i in range(n):
		if segment[i][0] == start:
			Cover_segment.add(segment[i][2])
		else:
			break
	segment.sort(key=lambda seg: seg[1], reverse=True)
	end = segment[0][1]
	for i in range(n):
		if segment[i][1] == end:
			if segment[i][2] in Cover_segment:
				print(segment[i][2])
				break
		else:
			print(-1)
			break

def main2():
	n = int(input())
	maxhead = 0
	minhead = 10 ** 9
	segments = []
	for _ in range(n):
		seg = list(map(int, input().split()))
		if seg[0] < minhead:
			minhead = seg[0]
		if seg[1] > maxhead:
			maxhead = seg[1]
		segments.append(seg)
	for i in range(n):
		if segments[i][0] == minhead and segments[i][1] == maxhead:
			print(i + 1)
			return
	print(-1)
main2()


n = int(input())
l = []
best = [0, -1]
k = -1
for i in range(n):
	l.append([int(x) for x in input().split()])
	if l[-1][1] - l[-1][0] > best[1] - best[0]:
		best = l[-1]
		k = i
for (a, b) in l:
	if a < best[0] or best[1] < b:
		print(-1)
		return
print(k + 1)


n = int(input())
l = 1000000000
r = 1
segs = []
for i in range(n):
	p = input().split()
	(a, b) = (int(p[0]), int(p[1]))
	if a < l:
		l = a
	if r < b:
		r = b
	segs.append((a, b))
v = -1
for i in range(len(segs)):
	if segs[i] == (l, r):
		v = i + 1
print(v)


def BigSegment(n):
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split())))
	M = arr[0][0]
	m = arr[0][1]
	index = 1
	for i in range(1, n):
		s = arr[i][0]
		d = arr[i][1]
		if not s <= d:
			return -1
		if s < M:
			M = s
			index = -1
		if d > m:
			m = d
			index = -1
		if arr[i][0] <= M and arr[i][1] >= m:
			M = arr[i][0]
			m = arr[i][1]
			index = i + 1
		elif arr[i][0] < M and arr[i][1] < m or (arr[i][0] > M and arr[i][1] > m):
			index = -1
	return index
print(BigSegment(int(input())))


n = int(input())
l = n * [0]
r = n * [0]
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
l_min = min(l)
r_max = max(r)
for i in range(n):
	if l[i] == l_min and r[i] == r_max:
		print(i + 1)
		exit()
print(-1)


from sys import stdin, stdout
if not __debug__:
	stdin = open('input.txt', 'r')
tcs = int(stdin.readline()) if not __debug__ else 1
t = 1
while t <= tcs:
	n = int(stdin.readline().strip())
	segs = []
	for _ in range(n):
		(l, r) = map(int, stdin.readline().split())
		segs.append([l, r])
	ss = sorted(range(len(segs)), key=lambda e: [segs[e][0], -segs[e][1]])
	se = sorted(segs, key=lambda x: [-x[1], x[0]])
	print(ss[0] + 1 if segs[ss[0]][1] >= se[0][1] else -1)
	t += 1


el = int(input())
minValue = 0
maxValue = 0
minSet = set()
maxSet = set()
ch = 0
for i in range(el):
	temp = []
	for j in input().split(' '):
		temp.append(int(j))
	if ch != 0:
		if temp[0] < minValue:
			minValue = temp[0]
			minSet = set()
			minSet.add(i + 1)
		elif temp[0] == minValue:
			minSet.add(i + 1)
		if temp[1] > maxValue:
			maxValue = temp[1]
			maxSet = set()
			maxSet.add(i + 1)
		elif temp[1] == maxValue:
			maxSet.add(i + 1)
	else:
		minValue = temp[0]
		maxValue = temp[1]
		minSet.add(i + 1)
		maxSet.add(i + 1)
		ch = 1
res = minSet & maxSet
if len(res) == 0:
	print(-1)
else:
	print(list(res)[0])


n = int(input())
li = []
x = list(map(int, input().split()))
li.append(x)
l = x[0]
r = x[1]
for i in range(n - 1):
	x = list(map(int, input().split()))
	if l > x[0]:
		l = x[0]
	if r < x[1]:
		r = x[1]
	li.append(x)
check = []
check.append(l)
check.append(r)
if check in li:
	for i in range(n):
		if li[i] == check:
			print(i + 1)
else:
	print('-1')


def main():
	n = int(input())
	(l, r) = ([], [])
	for _ in range(n):
		(a, b) = map(int, input().split())
		l.append(a)
		r.append(b)
	m = (min(l), max(r))
	for (i, a) in enumerate(zip(l, r)):
		if a == m:
			print(i + 1)
			return
	print(-1)
main()


def bigSegment():
	n = int(input())
	line = []
	for i in range(n):
		(a, b) = map(int, input().split())
		line.append((a, b))
	maxr = 0
	minl = 0
	for i in range(n):
		if line[i][1] > line[maxr][1]:
			maxr = i
	for i in range(n):
		if line[i][0] < line[minl][0]:
			minl = i
	for i in range(n):
		if line[i] == (line[minl][0], line[maxr][1]):
			print(i + 1)
			return
	print(-1)
bigSegment()


n = int(input())
(L, R) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	L.append(a)
	R.append(b)
(left, right) = (min(L), max(R))
for i in range(n):
	if left == L[i] and right == R[i]:
		print(i + 1)
		exit()
print(-1)


def findBigSegment(startAr, endAr, n):
	min = 10 ** 9 + 1
	minI = []
	max = 0
	for i in range(n):
		if startAr[i] < min:
			min = startAr[i]
	for i in range(n):
		if startAr[i] == min:
			minI.append(i)
	for j in range(n):
		if endAr[j] > max:
			max = endAr[j]
	for k in minI:
		if endAr[k] == max:
			return k + 1
	return -1
n = int(input())
startAr = []
endAr = []
for i in range(n):
	(start, end) = map(int, input().split())
	startAr.append(start)
	endAr.append(end)
print(findBigSegment(startAr, endAr, n))


n = int(input())
(begin, end) = map(int, input().split())
kc = begin - end
flag = True
ans = 1
for i in range(n - 1):
	(a, b) = map(int, input().split())
	if kc <= b - a and a <= begin and (b >= end):
		begin = a
		end = b
		kc = b - a
		ans = i + 2
		flag = True
	elif a >= begin and b <= end and (flag == True):
		flag = True
	else:
		flag = False
		if a <= begin:
			begin = a
		if b >= end:
			end = b
		kc = end - begin
if flag == False:
	print(-1)
else:
	print(ans)


n = int(input())
s = []
for _ in range(n):
	x = list(map(int, input().split()))
	s.append(x)
l = [s[i][0] for i in range(n)]
r = [s[j][1] for j in range(n)]
mini = min(l)
maxi = max(r)
f = 0
for k in range(n):
	if s[k][0] <= mini and s[k][1] >= maxi:
		f = 1
		a = k + 1
		break
if f == 0:
	print(-1)
else:
	print(a)


kalanbaba = 1
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = []
r = []
k = []
for i in range(n):
	(a, b) = I()
	l.append(a)
	r.append(b)
	k.append([a, b])
l.sort()
r.sort()
if [l[0], r[-1]] in k:
	print(k.index([l[0], r[-1]]) + 1)
else:
	print(-1)


n = int(input())
arrL = []
arrR = []
for i in range(n):
	(tempL, tempR) = map(int, input().split())
	arrL.append(tempL)
	arrR.append(tempR)
minL = min(arrL)
maxR = max(arrR)
ans = False
for i in range(n):
	if arrL[i] == minL and arrR[i] == maxR:
		ans = True
		break
if ans:
	print(i + 1)
else:
	print(-1)


import sys
import math
import bisect

def solve(A, B):
	n = len(A)
	l = min(A)
	r = max(B)
	for i in range(n):
		if A[i] <= l and B[i] >= r:
			return i + 1
	return -1

def main():
	n = int(input())
	A = []
	B = []
	for i in range(n):
		(a, b) = map(int, input().split())
		A.append(a)
		B.append(b)
	ans = solve(A, B)
	print(ans)
main()


n = int(input())
p = []
q = []
for i in range(n):
	(x, y) = map(int, input().split())
	p.append(x)
	q.append(y)
mn = min(p)
mx = max(q)
ans = False
for j in range(n):
	if p[j] == mn and q[j] == mx:
		ans = True
		fans = j
		break
if ans:
	print(fans + 1)
else:
	print(-1)


Narray = int(input())
ct = list(input().split())
ct = [int(x) for x in ct]
tmin = min(ct)
tmax = max(ct)
Aarray = [ct]
for i in range(Narray - 1):
	Barray = input().split()
	Barray = [int(y) for y in Barray]
	Aarray.append(list(Barray))
	dmax = max(Barray)
	dmin = min(Barray)
	if dmax >= tmax:
		tmax = dmax
	else:
		tmax = tmax
	if dmin <= tmin:
		tmin = dmin
	else:
		tmin = tmin
try:
	Type_value = Aarray.index([tmin, tmax]) + 1
except ValueError:
	Type_value = -1
print(Type_value)


n = int(input())
arr = []
for _ in range(n):
	(l, r) = map(int, input().split())
	arr.append((l, r, _ + 1))
arr.sort(key=lambda x: x[0])
Min = arr[0][0]
left = set()
for i in range(n):
	if arr[i][0] != Min:
		break
	else:
		left.add(arr[i][2])
arr.sort(key=lambda x: x[1], reverse=True)
Max = arr[0][1]
right = set()
for i in range(n):
	if arr[i][1] != Max:
		break
	else:
		right.add(arr[i][2])
ans = left & right
if ans:
	for i in ans:
		print(i)
else:
	print(-1)


n = int(input())
mini = 99999999999999999999999
maxi = -mini
arr = []
for _ in range(n):
	a = list(map(int, input().split()))
	arr.append(a)
	maxi = max(maxi, max(a))
	mini = min(mini, min(a))
a = 0
flag = 0
for i in range(len(arr)):
	item = arr[i]
	if item[0] <= mini and item[1] >= maxi:
		flag = 1
		break
if flag == 1:
	print(i + 1)
if flag == 0:
	print(-1)


n = int(input())
(v1, v2) = ([], [])
for i in range(n):
	(a, b) = map(int, input().split(' '))
	v1.append(a)
	v2.append(b)
(a, b) = (min(v1), max(v2))
t = 0
for i in range(n):
	if v1[i] <= a and v2[i] >= b:
		print(i + 1)
		t = 1
		break
if t == 0:
	print(-1)


def main():
	n = int(input())
	segmentos = [tuple([int(x) for x in input().split()]) for _ in range(n)]
	(minimo_inicio, indice) = Min(segmentos, n)
	if max(segmentos, key=lambda tupla: tupla[1])[1] == minimo_inicio[1]:
		print(indice + 1)
	else:
		print(-1)

def Min(segmentos, n):
	minimo = segmentos[0]
	i = 0
	for j in range(n):
		if segmentos[j][0] < minimo[0]:
			minimo = segmentos[j]
			i = j
		elif segmentos[j][0] == minimo[0]:
			if segmentos[j][1] > minimo[1]:
				minimo = segmentos[j]
				i = j
	return (minimo, i)
main()


n = int(input())
S = []
for i in range(n):
	S.append(list(map(int, input().split())) + [i + 1])
S.sort()
min_a = S[0][0]
max_b = 0
for x in S:
	if max_b < x[1]:
		max_b = x[1]
for p in range(n):
	if S[p][0] == min_a and S[p][1] == max_b:
		print(S[p][2])
		exit()
print(-1)


z = []
x1 = y = []
n = int(input())
for x in range(n):
	(p, q) = map(int, input().split())
	x1.append(p)
	y.append(q)
	z.append([p, q])
n1 = min(x1)
n2 = max(y)
for x in range(n):
	if z[x][0] == n1 and z[x][1] == n2:
		print(x + 1)
		break
else:
	print(-1)


n = int(input())
left = list()
right = list()
for index in range(0, n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
minl = min(left)
maxr = max(right)
found = -1
for index in range(0, n):
	if left[index] == minl and right[index] == maxr:
		found = index
		break
if found == -1:
	print(found)
else:
	print(found + 1)


tests = int(input())
(a, b) = (1000000000.0, 0)
l = []
r = []
for i in range(tests):
	(p, q) = list(map(int, input().split()))
	l.append(p)
	r.append(q)
	if a >= p:
		a = p
	if b <= q:
		b = q
ans = -1
for q in range(len(l)):
	if l[q] == a and r[q] == b:
		ans = q + 1
		break
print(ans)


S = [tuple(map(int, input().split())) for _ in range(int(input()))]
(a, b) = (min((L for (L, _) in S)), max((R for (_, R) in S)))
for (i, (L, R)) in enumerate(S, 1):
	if (L, R) == (a, b):
		print(i)
		break
else:
	print(-1)


number = int(input())
list_array = []
for i in range(number):
	list_array.append(str(input()).split())
x = 1
minx = int(list_array[0][0])
maxx = int(list_array[0][1])
for ii in range(number - 1):
	a1 = list_array[ii + 1]
	if int(a1[0]) <= minx and int(a1[1]) >= maxx:
		x = ii + 2
		minx = int(a1[0])
		maxx = int(a1[1])
	if int(a1[0]) < minx and int(a1[1]) < maxx:
		x = -1
		minx = int(a1[0])
	if int(a1[0]) > minx and int(a1[1]) > maxx:
		x = -1
		maxx = int(a1[1])
print(x)


def solve():
	n = int(input())
	x = []
	y = []
	for i in range(n):
		(a, b) = map(int, input().split())
		x.append(a)
		y.append(b)
	maxm = max(y)
	minm = min(x)
	c = -100
	for i in range(n):
		if y[i] == maxm and x[i] == minm:
			c = i + 1
			break
	if c == -100:
		print(-1)
		return
	print(c)
	return
try:
	solve()
except:
	pass


number_segment = int(input(''))
count = 0
s = list()
while count < number_segment:
	s.append(list(map(int, input('').split())))
	count += 1
left = list()
right = list()
for item in s:
	left.append(item[0])
	right.append(item[1])
cover_segment = [min(left), max(right)]
i = 0
flag = False
while i < len(s) and flag == False:
	if s[i] == cover_segment:
		flag = True
	i += 1
if flag:
	print(i)
else:
	print(-1)


def main():
	n = int(input())
	ls = []
	lmin = 999999999999999999999999999
	rmax = 0
	for i in range(n):
		(l, r) = [int(j) for j in input().split()]
		lmin = min(l, lmin)
		rmax = max(rmax, r)
		ls.append((l, r))
	if (lmin, rmax) in ls:
		print(ls.index((lmin, rmax)) + 1)
		return 0
	print(-1)
	return 0
main()


n = int(input())
seg = []
mn = 100000000000.0
mx = -1
for i in range(n):
	(l, r) = map(int, input().split())
	if l < mn:
		mn = l
	if r > mx:
		mx = r
	seg.append((l, r))
try:
	ind = seg.index((mn, mx))
	print(ind + 1)
except:
	print(-1)


t = int(input())
m = 10 ** 9 + 1
mx = -1
l = []
for i in range(t):
	(a, b) = map(int, input().split())
	l.append((a, b))
	if a < m:
		m = a
	if b > mx:
		mx = b
if (m, mx) in l:
	print(l.index((m, mx)) + 1)
else:
	print(-1)


n = int(input())
l = []
r = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
minL = min(l)
maxR = max(r)
found = False
for i in range(n):
	if l[i] == minL and r[i] == maxR:
		print(i + 1)
		found = True
if found == False:
	print(-1)


(min_a, max_b) = (10 ** 10, 0)
(min_A, max_B) = (10 ** 10, 0)
cur_index = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a < min_A:
		min_A = a
	if b > max_B:
		max_B = b
	if a <= min_a and b >= max_b:
		min_a = a
		max_b = b
		cur_index = i + 1
if min_a == min_A and max_b == max_B:
	print(cur_index)
else:
	print(-1)


def main():
	N = int(input())
	(mic, mac) = map(int, input().split())
	index = 1
	(mix, may) = (mic, mac)
	for i in range(2, N + 1):
		(a, b) = map(int, input().split())
		if a < mix:
			mix = a
		if b > may:
			may = b
		if a <= mic and b >= mac:
			(mic, mac) = (a, b)
			index = i
	if mic == mix and mac == may:
		print(index)
	else:
		print(-1)
main()


from sys import stdin, stdout
import sys
INF = 100000000000.0
import bisect

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

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

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
import math
n = get_int()
a = []
m1 = INF
m2 = -INF
ans = 0
for i in range(n):
	(x, y) = get_ints()
	a.append((x, y, i + 1))
b = sorted(a, key=lambda x: x[0])
a = sorted(a, key=lambda x: x[1], reverse=True)
x = b[0][0]
y = a[0][1]
for i in range(n):
	if a[i][0] == x and a[i][1] == y:
		print(a[i][2])
		break
else:
	print(-1)


n = int(input())
a = 1000000001
b = i1 = i2 = -1
for i in range(n):
	(x, y) = map(int, input().split())
	if x < a:
		a = x
		i1 = i
	elif x == a and y >= b:
		i1 = i2 = i
		b = y
	if y > b:
		b = y
		i2 = i
	elif y == b and x <= a:
		a = x
		i1 = i2 = i
if i1 == i2:
	print(i1 + 1)
else:
	print(-1)


def arrays():
	par1 = int(input())
	if par1 == 1:
		return 1
	listpar = []
	for i in range(par1):
		listpar.append([])
		listpar[i] = list(map(int, input().split()[0:2]))
	minmax = []
	minmax.append(listpar[0][0])
	minmax.append(listpar[0][1])
	for i in range(1, par1):
		if listpar[i][0] < minmax[0]:
			minmax[0] = listpar[i][0]
		if listpar[i][1] > minmax[1]:
			minmax[1] = listpar[i][1]
	for m in range(par1):
		if listpar[m][0] == minmax[0] and listpar[m][1] == minmax[1]:
			return m + 1
	return -1
print(arrays())


n = int(input())
chuoinho = [0] * n
chuoilon = [0] * n
for i in range(n):
	(chuoinho[i], chuoilon[i]) = map(int, input().split())
x = min(chuoinho)
y = max(chuoilon)
for i in range(n):
	if chuoinho[i] == x and chuoilon[i] == y:
		print(i + 1)
		exit(0)
print(-1)


n = int(input())
a = []
b = []
for i in range(n):
	(tempA, tempB) = map(int, input().split())
	a.append(tempA)
	b.append(tempB)
min = a[0]
max = b[0]
for i in range(n):
	if a[i] < min:
		min = a[i]
	if b[i] > max:
		max = b[i]
res = -1
for i in range(n):
	if a[i] == min and b[i] == max:
		res = i + 1
		break
print(res)


z = []
n = int(input())
c1 = 1000000000
c2 = 0
for x in range(n):
	(p, q) = map(int, input().split())
	if p < c1:
		c1 = p
	if q > c2:
		c2 = q
	z.append([p, q])
for x in range(n):
	if z[x][0] == c1 and z[x][1] == c2:
		print(x + 1)
		break
else:
	print(-1)


(x, y) = (10000000000, -10000000000)
(c, d) = (0, 0)
e = 0
f = -76
for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = min(x, a)
	y = max(y, b)
	if b - a > f:
		f = b - a
		c = a
		d = b
		e = i + 1
if c == x and d == y:
	print(e)
else:
	print(-1)


templ = None
for i in range(int(input())):
	(l, r) = map(int, input().split())
	if templ == None:
		templ = l
		tempr = r
		Ans = 1
	elif l <= templ and r >= tempr:
		templ = l
		tempr = r
		Ans = i + 1
	elif l < templ:
		templ = l
		Ans = -1
	elif r > tempr:
		tempr = r
		Ans = -1
print(Ans)


import sys
import math
n = int(sys.stdin.readline())
d = []
vmin = 1000000001
vmax = 0
for i in range(n):
	(l, r) = [int(x) for x in sys.stdin.readline().split()]
	d.append((i + 1, (l, r)))
	if l < vmin:
		vmin = l
	if r > vmax:
		vmax = r
k = -1
for i in d:
	if i[1][0] <= vmin and i[1][1] >= vmax:
		k = i[0]
print(k)


Segments = []
(Min, Max) = (10 ** 9, 0)
for i in range(int(input())):
	Temp = input()
	Temp2 = list(map(int, Temp.split()))
	(Min, Max) = (min(Min, Temp2[0]), max(Max, Temp2[1]))
	Segments.append(Temp)
print(Segments.index(str(Min) + ' ' + str(Max)) + 1 if str(Min) + ' ' + str(Max) in Segments else -1)


import sys
import math
n = int(sys.stdin.readline())
d = []
vmin = 1000000001
vmax = 0
for i in range(n):
	(l, r) = [int(x) for x in sys.stdin.readline().split()]
	d.append((i + 1, (l, r)))
	if l < vmin:
		vmin = l
	if r > vmax:
		vmax = r
d.sort(key=lambda x: x[1][0])
k = -1
for i in d:
	if i[1][0] <= vmin:
		if i[1][1] >= vmax:
			k = i[0]
	else:
		break
print(k)


n = int(input())
a = [tuple(map(int, input().split())) for x in range(n)]
b = min([x[0] for x in a])
c = max([x[1] for x in a])
if (b, c) in a:
	print(a.index((b, c)) + 1)
else:
	print(-1)


n = int(input())
l = []
r = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
m1 = min(l)
m2 = max(r)
flag = 0
for i in range(n):
	if l[i] == m1 and r[i] == m2:
		print(i + 1)
		flag = 1
		break
if flag == 0:
	print(-1)


n = int(input())
(lowest, highest) = (1000000001, 0)
segments = []
for i in range(n):
	(l, r) = map(int, input().split())
	if l <= lowest:
		lowest = l
	if r >= highest:
		highest = r
	segments.append([l, r])
if [lowest, highest] in segments:
	print(segments.index([lowest, highest]) + 1)
else:
	print(-1)


n = int(input())
a = []
(X, Y) = map(int, input().split())
a.append((X, Y))
for i in range(n - 1):
	(x, y) = map(int, input().split())
	X = min(X, x)
	Y = max(Y, y)
	a.append((x, y))
res = -1
for i in range(n):
	if a[i][0] == X and a[i][1] == Y:
		res = i + 1
		break
print(res)


n = int(input())
l = []
r = []
for i in range(0, n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
a = min(l)
b = max(r)
s1 = set()
for i in range(0, n):
	if l[i] == a:
		s1.add(i)
for j in range(0, n):
	if r[j] == b:
		if j in s1:
			print(j + 1)
			break
else:
	print(-1)


n = int(input())
segs = [[0, 0] for _ in range(n)]
mi = 10 ** 9
ma = 0
for i in range(n):
	(a, b) = map(int, input().split())
	mi = min(mi, a)
	ma = max(ma, b)
	segs[i] = [a, b]
if [mi, ma] not in segs:
	print(-1)
else:
	for i in range(n):
		if segs[i] == [mi, ma]:
			print(i + 1)
			break


t = int(input())
first = []
second = []
overall = []
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	first.append(a)
	second.append(b)
	overall.append([a, b])
mi = min(first)
ma = max(second)
flag = -1
for i in range(t):
	if overall[i][0] <= mi <= ma <= overall[i][1]:
		flag = i + 1
print(flag)


n = int(input())
l = []
low = pow(10, 9)
high = -1
for t1 in range(0, n):
	(a, b) = map(int, input().split())
	l.append((a, b))
	low = min(low, a)
	high = max(high, b)
check = -1
for i in l:
	if i[0] <= low and i[1] >= high:
		check = 1
		print(l.index(i) + 1)
		break
if check == -1:
	print(-1)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = iinput()
s1 = []
s2 = []
for i in range(n):
	s = list(map(int, input().split()))
	s1.append(s[0])
	s2.append(s[1])
l = min(s1)
l1 = max(s1)
m = max(s2)
a = []
b = []
for i in range(len(s1)):
	if s1[i] == l:
		a.append(i)
for i in range(len(s2)):
	if s2[i] == m:
		b.append(i)
c = list(set(a).intersection(b))
count = len(c)
if count != 1:
	print(-1)
elif l1 <= m:
	print(c[0] + 1)


n = int(input())
segs = [list(map(int, input().split())) for _ in range(n)]
l = 99999999999999999
r = 0
for s in segs:
	l = min(l, s[0])
	r = max(r, s[1])
for (i, s) in enumerate(segs):
	if s[0] == l and s[1] == r:
		print(i + 1)
		break
else:
	print('-1')


n = int(input())
(l, r) = ([0] * n, [0] * n)
(L, R) = (1000000001, 0)
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
	(L, R) = (min(L, l[i]), max(R, r[i]))
f = True
for i in range(n):
	if l[i] == L and r[i] == R:
		print(i + 1)
		f = False
		break
if f:
	print(-1)


n = int(input())
(Left, Right) = (0, 0)
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
Left = min(a)
Right = max(b)
res = -1
for i in range(n):
	if a[i] <= Left and Right <= b[i]:
		res = i + 1
		break
print(res)


n = int(input())
li = []
for i in range(n):
	(a, b) = map(int, input().split(' '))
	t = (a, b)
	li.append(t)
sl = sorted(li, key=lambda x: (x[0], -x[1]))
first = sl[0]
sl = sorted(li, key=lambda x: x[1])
last = sl[len(sl) - 1]
if last[1] > first[1]:
	print(-1)
else:
	index = li.index(first) + 1
	print(index)


number = int(input())
(masx, masy) = ([0] * number, [0] * number)
for i in range(number):
	(masx[i], masy[i]) = map(int, input().split())
x = min(masx)
y = max(masy)
for i in range(number):
	if masx[i] == x and masy[i] == y:
		print(i + 1)
		exit(0)
print(-1)


def solve(lines):
	minidx = set()
	minidx.add(0)
	maxidx = set()
	maxidx.add(0)
	mincand = 0
	maxcand = 0
	if len(lines) == 0:
		return -1
	if len(lines) == 1:
		return 1
	for i in range(1, len(lines)):
		if lines[i][0] < lines[mincand][0]:
			minidx = set()
			minidx.add(i)
			mincand = i
		elif lines[i][0] <= lines[mincand][0]:
			minidx.add(i)
		if lines[i][1] > lines[maxcand][1]:
			maxidx = set()
			maxidx.add(i)
			maxcand = i
		elif lines[i][1] >= lines[maxcand][1]:
			maxidx.add(i)
	res = list(minidx.intersection(maxidx))
	if res:
		return res[0] + 1
	return -1
n = int(input())
lines = []
for i in range(n):
	nums = list(map(int, input().split()))
	lines.append(nums)
print(solve(lines))


from sys import stdin, stdout
n = int(stdin.readline())
(l, r) = ([], [])
for _ in range(n):
	(a, b) = stdin.readline().split()
	l.append(int(a))
	r.append(int(b))
(mini, maxi) = (min(l), max(r))
mnind = [i + 1 for (i, x) in enumerate(l) if x == mini]
mxind = [i + 1 for (i, x) in enumerate(r) if x == maxi]
p = list(set(mnind).intersection(mxind))
if len(p) == 0:
	stdout.write('-1')
else:
	stdout.write(str(p[0]))


import sys
n = int(sys.stdin.readline())
minn = None
maxx = None
curr = None
lr = []
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().split())
	lr.append((l, r))
	if not minn:
		minn = l
	if l < minn:
		minn = l
	if not maxx:
		maxx = r
	if r > maxx:
		maxx = r
	if (l, r) == (minn, maxx):
		curr = i
if lr[curr] == (minn, maxx):
	print(curr + 1)
else:
	print(-1)


n = int(input())
a = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	a.append([i, l, r, r - l])
l1 = sorted(a, reverse=True, key=lambda x: x[3])
l2 = sorted(a, reverse=True, key=lambda x: x[2])
l3 = sorted(a, key=lambda x: x[1])
if l2[0][2] - l3[0][1] != l1[0][3]:
	print('-1')
else:
	print(l1[0][0] + 1)


n = int(input())
a = []
minLeft = 1000000009
maxRight = 0
for i in range(0, n):
	(u, v) = map(int, input().split(' '))
	a.append({u, v})
	minLeft = min(minLeft, u)
	maxRight = max(maxRight, v)
for i in range(0, n):
	if a[i] == {minLeft, maxRight}:
		print(i + 1)
		exit()
print(-1)


n = int(input())
min = 1000000001
max = 0
arr = []
while n > 0:
	(l, r) = [int(x) for x in input().split()]
	arr.append([l, r])
	if l < min:
		min = l
	if r > max:
		max = r
	n = n - 1
flag = 0
for i in range(len(arr)):
	if arr[i][0] <= min and arr[i][1] >= max:
		flag = 1
		print(i + 1)
		break
if flag == 0:
	print('-1')


class Segment:

	def __init__(self, i, l, r):
		self.i = i
		self.l = l
		self.r = r
n = int(input())
segments = []
for i in range(n):
	(l, r) = map(int, input().split())
	segment = Segment(i + 1, l, r)
	segments.append(segment)
minimumL = segments[0].l
maximumR = segments[0].r
index = 1
for i in range(1, n):
	if segments[i].l < minimumL:
		minimumL = segments[i].l
		if segments[i].r < maximumR:
			index = -1
		else:
			index = segments[i].i
			maximumR = segments[i].r
	elif segments[i].l == minimumL:
		if segments[i].r >= maximumR:
			maximumR = segments[i].r
			index = segments[i].i
	elif maximumR < segments[i].r:
		index = -1
		maximumR = segments[i].r
print(index)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
(l, r) = (10 ** 9, 1)
for i in a:
	l = min(l, i[0])
	r = max(r, i[1])
ans = -1
for i in range(n):
	if a[i][0] == l and a[i][1] == r:
		ans = i + 1
		break
print(ans)


def main():
	n = int(input())
	segments = []
	min_l = float('inf')
	max_r = 0
	for i in range(n):
		(l, r) = map(int, input().split())
		min_l = min(min_l, l)
		max_r = max(max_r, r)
		segments.append((l, r))
	index = -1
	for i in range(n):
		if segments[i][0] <= min_l and segments[i][1] >= max_r:
			index = i + 1
			break
	print(index)
main()


listnum = []
for x in range(0, int(input())):
	(a, b) = map(int, input().split())
	listnum.append([a, b])
l = min((i[0] for i in listnum))
r = max((i[1] for i in listnum))
if [l, r] in listnum:
	print(listnum.index([l, r]) + 1)
else:
	print(-1)


class Seg:

	def __init__(self, l, r):
		self.l = l
		self.r = r
n = int(input())
lst = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	lst.append(Seg(l, r))
R = 0
L = 10 ** 9 + 1
for x in lst:
	R = max(R, x.r)
	L = min(L, x.l)
index = -2
for i in range(n):
	if lst[i].l == L and lst[i].r == R:
		index = i
print(index + 1)


def main():
	n = int(input())
	segment = []
	for i in range(n):
		(first, last) = map(int, input().split())
		segment.append((first, last, i + 1))
	segment.sort(key=lambda seg: seg[0])
	Cover_segment = set()
	start = segment[0][0]
	for i in range(n):
		if segment[i][0] == start:
			Cover_segment.add(segment[i][2])
		else:
			break
	segment.sort(key=lambda seg: seg[1], reverse=True)
	end = segment[0][1]
	for i in range(n):
		if segment[i][1] == end:
			if segment[i][2] in Cover_segment:
				print(segment[i][2])
				break
		else:
			print(-1)
			break

def main2():
	n = int(input())
	maxhead = 0
	minhead = 10 ** 9
	segments = []
	for _ in range(n):
		seg = list(map(int, input().split()))
		if seg[0] < minhead:
			minhead = seg[0]
		if seg[1] > maxhead:
			maxhead = seg[1]
		segments.append(seg)
	for i in range(n):
		if segments[i][0] == minhead and segments[i][1] == maxhead:
			print(i + 1)
			return
	print(-1)

def main3():
	n = int(input())
	(small, big) = (float('inf'), float('-inf'))
	res = -1
	for i in range(n):
		(a, b) = map(int, input().split())
		if a < small:
			small = a
			res = -1
		if b > big:
			big = b
			res = -1
		if a == small and b == big:
			res = i + 1
	print(res)
main3()


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def valid(row, col, rows, cols, rcross, lcross):
	return rows[row] == 0 and cols[col] == 0 and (rcross[col + row] == 0) and (lcross[col - row] == 0)

def div(n):
	tmp = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			cnt = 0
			while n % i == 0:
				n = n // i
				cnt += 1
			tmp.append((i, cnt))
	if n > 1:
		tmp.append((n, 1))
	return tmp

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		flag = True
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				flag = False
				break
		return flag

def s(b):
	ans = []
	while b > 0:
		tmp = b % 10
		ans.append(tmp)
		b = b // 10
	return ans

def main():
	n = ii()
	left = math.inf
	right = -math.inf
	points = []
	for i in range(n):
		(l, r) = mi()
		left = min(left, l)
		right = max(right, r)
		points.append((l, r))
	flag = -1
	for i in range(n):
		if points[i][0] <= left and points[i][1] >= right:
			flag = i + 1
			break
	print(flag)
main()


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
min = 10 ** 9
max = 0
for i in range(n):
	if x[i] < min:
		min = x[i]
for j in range(n):
	if y[j] > max:
		max = y[j]
tf = False
for i in range(n):
	if x[i] == min and y[i] == max:
		tf = True
		print(i + 1)
if tf == False:
	print('-1')


(vl, vr, vi, maxr) = (1000000001, 0, 0, 0)
for i in range(1, int(input()) + 1):
	(l, r) = (int(x) for x in input().split())
	if l < vl or (l == vl and r > vr):
		(vl, vr, vi) = (l, r, i)
	maxr = max(maxr, r)
print(vi if vr >= maxr else -1)


x = int(input())
i = 1
segmentsss = []
while i <= x:
	i += 1
	segment = list(map(int, input().split()))
	segmentsss.append(segment)
xmin = min((l[0] for l in segmentsss))
index_x = []
for i in range(len(segmentsss)):
	if segmentsss[i][0] == xmin:
		index_x.append(i + 1)
ymax = max((m[1] for m in segmentsss))
index_y = []
for i in range(len(segmentsss)):
	if segmentsss[i][1] == ymax:
		index_y.append(i + 1)
overlap = list(set(index_x) & set(index_y))
if len(overlap) == 0:
	print(-1)
else:
	print(overlap[0])


a = int(input())
b = [0 for i in range(a)]
c = [0 for i in range(a)]
xmin = 1000000000
ymax = 0
mini = -1
for i in range(a):
	(b[i], c[i]) = [int(i) for i in input().split()]
xmin = min(b)
ymax = max(c)
for i in range(a):
	if b[i] == xmin and c[i] == ymax:
		mini = i + 1
print(mini)


import math
import sys
n = int(input())
l = 10 ** 9
r = 0
t = []
for i in range(n):
	(a, b) = map(int, input().split())
	l = min(l, a)
	r = max(r, b)
	t.append([a, b])
for (i, p) in enumerate(t):
	if p[0] == l and p[1] == r:
		exit(print(i + 1))
print(-1)


min_val = float('inf')
max_val = float('-inf')
min_idx = max_idx = 0
idx = 1
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == min_val and y == max_val:
		if min_idx != max_idx:
			min_idx = max_idx = idx
	elif x <= min_val and y >= max_val:
		min_idx = max_idx = idx
	elif x < min_val:
		min_idx = idx
	elif y > max_val:
		max_idx = idx
	min_val = min(x, min_val)
	max_val = max(y, max_val)
	idx += 1
if min_idx == max_idx:
	print(min_idx)
else:
	print(-1)


(n, mn, mx, arr) = (input(), 1000000000, 0, [])
for _ in range(int(n)):
	(*a,) = map(int, input().split())
	(mn, mx) = (min(mn, a[0]), max(mx, a[1]))
	arr.append(a)
print(arr.index([mn, mx]) + 1 if [mn, mx] in arr else -1)


n = int(input())
ml = 10000000000.0
mr = 0
L = []
for i in range(n):
	t = []
	(l, r) = map(int, input().split())
	if l <= ml:
		ml = l
	if r >= mr:
		mr = r
	t.append(l)
	t.append(r)
	L.append(t)
c = 0
for i in range(len(L)):
	if L[i][0] == ml and L[i][1] == mr:
		c = 1
		p = i + 1
		break
if c == 1:
	print(p)
else:
	print('-1')


n = int(input())
b = []
c = []
for i in range(n):
	a = list(map(int, input().split(' ')))
	b.append(a[0])
	c.append(a[1])
e = max(c)
f = min(b)
c1 = 0
for j in range(len(b)):
	if b[j] == f and c[j] == e:
		c1 += 1
		x = j + 1
if c1 == 1:
	print(x)
else:
	print(-1)


n = int(input())
c = [0] * n
d = [0] * n
minn = 1000000000000000000000000000000000
maxx = 0
for i in range(n):
	(c[i], d[i]) = map(int, input().split())
	if minn > c[i]:
		minn = c[i]
	if maxx < d[i]:
		maxx = d[i]
for j in range(n):
	if c[j] == minn and d[j] == maxx:
		print(j + 1)
		exit(0)
print('-1')


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
front = sorted(arr, key=lambda x: x[1] - x[0], reverse=True)
min1 = min(arr, key=lambda x: x[0])[0]
max2 = max(arr, key=lambda x: x[1])[1]
if min1 >= front[0][0] and max2 <= front[0][1]:
	print(arr.index(front[0]) + 1)
else:
	print(-1)


n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
xmin = min((l[0] for l in arr))
x_index = []
for i in range(n):
	if arr[i][0] == xmin:
		x_index.append(i + 1)
ymax = max((r[1] for r in arr))
y_index = []
for i in range(n):
	if arr[i][1] == ymax:
		y_index.append(i + 1)
res = list(set(x_index) & set(y_index))
print(-1 if len(res) == 0 else res[0])


def main():
	N = int(input())
	segments = []
	iN = 0
	while iN < N:
		segments.append(list(map(int, input().split())))
		iN += 1
	indexOfGreatest = -1
	greatLeft = segments[0][0]
	greatRight = segments[0][1]
	for i in range(1, N):
		if segments[i][0] < greatLeft:
			greatLeft = segments[i][0]
		if segments[i][1] > greatRight:
			greatRight = segments[i][1]
	for i in range(0, N):
		if segments[i] == [greatLeft, greatRight]:
			indexOfGreatest = i + 1
	print(indexOfGreatest)
	return True
main()


class Segment:

	def __init__(self, l, r):
		self.l = l
		self.r = r
n = int(input())
a = []
minl = 1000000000.0
maxr = 0
for i in range(n):
	(l, r) = map(int, input().split())
	a.append(Segment(l, r))
	if l < minl:
		minl = l
	if r > maxr:
		maxr = r
found = False
for x in a:
	if x.l == minl and x.r == maxr:
		found = True
		print(a.index(x) + 1)
		break
if not found:
	print(-1)


n = int(input())
s1 = []
s2 = []
for i in range(n):
	(r, l) = map(int, input().split())
	s1.append(r)
	s2.append(l)

def big_segment(a1, a2):
	highest = max(a2)
	lowest = min(a1)
	for i in range(len(a1)):
		if a1[i] == lowest:
			if a2[i] == highest:
				return i + 1
	return -1
print(big_segment(s1, s2))


n = int(input())
count = 0
flag = False
l_min = 10 ** 9
r_max = 1
for _ in range(n):
	(l, r) = map(int, input().split())
	if l <= l_min and r >= r_max:
		l_min = l
		r_max = r
		flag = True
		count = _ + 1
	elif l < l_min:
		l_min = l
		flag = False
	elif r > r_max:
		r_max = r
		flag = False
if flag:
	print(count)
else:
	print(-1)


n = int(input())
a = [0] * n
b = [0] * n
count = 0
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
x = min(a)
y = max(b)
for i in range(n):
	if a[i] == x and b[i] == y:
		print(i + 1)
		exit(0)
print(-1)


def main():
	n = int(input())
	segments = []
	for i in range(n):
		segments.append(input().split(' '))
	max_range = max((int(segments[i][1]) for i in range(n)))
	min_range = min((int(segments[i][0]) for i in range(n)))
	index = -1
	for i in range(n):
		if int(segments[i][0]) == min_range and int(segments[i][1]) == max_range:
			index = i + 1
	print(index)
main()


n = int(input())
ranges = {}
for i in range(n):
	(l, r) = map(int, input().split())
	ranges[l, r] = i
_min = 10 ** 9
_max = 0
for range in ranges:
	_min = min(_min, range[0])
	_max = max(_max, range[1])
if (_min, _max) in ranges:
	print(ranges[_min, _max] + 1)
else:
	print(-1)


n = int(input())
leftmin = 1000000001
rightmax = -1
index = 0
length = -1
left = 0
right = 0
for i in range(n):
	(a, b) = map(int, input().split())
	leftmin = min(leftmin, a)
	rightmax = max(rightmax, b)
	if abs(a - b) > length:
		length = abs(a - b)
		index = i
		left = a
		right = b
if left == leftmin and right == rightmax:
	print(index + 1)
else:
	print('-1')


n = int(input())
l = []
r = []
res = -1
for i in range(0, n):
	(temp_n, temp_m) = map(int, input().split())
	l.append(temp_n)
	r.append(temp_m)
leftMin = 99999999999
rightMax = 0
for i in range(0, n):
	leftMin = min(leftMin, l[i])
	rightMax = max(rightMax, r[i])
for i in range(0, n):
	if leftMin == l[i] and rightMax == r[i]:
		res = i + 1
		break
print(res)


from sys import stdin, stdout
n = int(stdin.readline())
A = []
MinA = 1000000001
MaxB = 0
for i in stdin.readlines():
	(a, b) = map(int, i.split())
	A.append([a, b])
	MinA = min(MinA, a)
	MaxB = max(MaxB, b)
Ind = -1
for i in range(0, n):
	if A[i][0] == MinA and A[i][1] == MaxB:
		Ind = i + 1
		break
print(Ind)


n = int(input())
segments = []
left = 10 ** 9 + 1
right = 0
for i in range(n):
	(l, r) = map(int, input().split())
	segments.append([l, r])
	if l < left:
		left = l
	if r > right:
		right = r
ans = -2
for i in range(n):
	if segments[i][0] <= left and segments[i][1] >= right:
		ans = i
		break
print(ans + 1)


n = int(input())
l = []
r = []
for i in range(n):
	(l1, r1) = map(int, input().split())
	l.append(l1)
	r.append(r1)
l2 = min(l)
r2 = max(r)
f = -1
for i in range(n):
	if l[i] == l2 and r[i] == r2:
		f = i + 1
		break
print(f)


n = int(input())
A = []
for _ in range(n):
	(x, y) = map(int, input().split())
	A.append([x, y])
l = 10 ** 9 + 1
r = 0
for i in A:
	l = min(l, i[0])
	r = max(r, i[1])
loc = -1
for i in range(n):
	if A[i][0] == l and A[i][1] == r:
		loc = i + 1
		break
print(loc)


n = int(input())
L = []
aG = 0
mini = 1000000000
maxi = -1000000000
for i in range(0, n):
	a = input().rstrip().split(' ')
	L.append(a)
	if int(a[0]) <= mini and int(a[1]) >= maxi:
		G = int(a[0])
		H = int(a[1])
		S = i
		mini = int(a[0])
		maxi = int(a[1])
for i in range(0, len(L)):
	A = L[i]
	if int(A[0]) >= mini and int(A[0]) <= maxi and (int(A[1]) >= mini) and (int(A[1]) <= maxi):
		continue
	else:
		aG = 1
		break
if aG == 1:
	print(-1)
else:
	print(S + 1)


n = int(input())
segs = []
for i in range(n):
	tmp = input()
	s = [int(x) for x in tmp.split()]
	segs.append(s)
prev = segs[0]
maxEnd = segs[0][1]
ans = 0
for j in range(1, len(segs)):
	if segs[j][0] < prev[0]:
		prev = segs[j]
		ans = j
	if segs[j][0] == prev[0] and segs[j][1] > prev[1]:
		prev = segs[j]
		ans = j
	if segs[j][1] > maxEnd:
		maxEnd = segs[j][1]
if prev[1] < maxEnd:
	print(-1)
else:
	print(ans + 1)


n = int(input())
l1 = []
r1 = []
for i in range(n):
	(l, r) = map(int, input().strip().split(' '))
	l1.append(l)
	r1.append(r)
m1 = 10 ** 9 + 1
m2 = 0
t = 0
for i in range(n):
	if l1[i] <= m1 and r1[i] >= m2:
		t = i
		m1 = l1[i]
		m2 = r1[i]
if m1 == min(l1) and m2 == max(r1):
	print(t + 1)
else:
	print(-1)


n = int(input())
list_l = []
list_r = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	list_l.append(l)
	list_r.append(r)
left = min(list_l)
right = max(list_r)
res = -1
for i in range(n):
	if list_l[i] == left and list_r[i] == right:
		res = i + 1
print(res)


def BigSegment(n, a):
	min1 = a[0][0]
	max1 = a[0][1]
	for i in range(len(a)):
		if a[i][0] < min1:
			min1 = a[i][0]
		if a[i][1] > max1:
			max1 = a[i][1]
	b = []
	b.append(min1)
	b.append(max1)
	if b in a:
		return a.index(b) + 1
	else:
		return -1
n = int(input())
a = []
for i in range(n):
	b = [int(x) for x in input().split()]
	a.append(b)
print(BigSegment(n, a))


nums = int(input())
first = []
second = []
p = [int(i) for i in input().split()]
less = p[0]
great = p[1]
first.append(p[0])
second.append(p[1])
answer = 1
for i in range(nums - 1):
	d = [int(i) for i in input().split()]
	first.append(d[0])
	second.append(d[1])
	if d[0] <= less and d[1] >= great:
		less = d[0]
		great = d[1]
		answer = i + 2
if great == max(second) and less == min(first):
	print(answer)
else:
	print(-1)


n = int(input())
L = []
R = []
pair = []
for i in range(n):
	(l, r) = input().split()
	L.append(int(l))
	R.append(int(r))
	pair.append(l + '-' + r)
minL = min(L)
maxR = max(R)
if str(minL) + '-' + str(maxR) in pair:
	print(pair.index(str(minL) + '-' + str(maxR)) + 1)
else:
	print(-1)


n = int(input())
li = []
flag = 1
for i in range(n):
	(x, y) = map(int, input().split())
	li.append([x, y, i])
li = sorted(li, key=lambda x: x[0])
s = li[0][0]
f = li[0][1]
j = -1
for i in range(n):
	if s == li[i][0] and f <= li[i][1]:
		f = li[i][1]
		j = li[i][2] + 1
	if f < li[i][1]:
		print(-1)
		quit()
print(j)


n = int(input())
lis_segment = []
for i in range(n):
	lis_segment.append(list(map(int, input().split())))
l = min((x[0] for x in lis_segment))
r = max((y[1] for y in lis_segment))
if [l, r] in lis_segment:
	print(lis_segment.index([l, r]) + 1)
else:
	print(-1)