n=int(input()) i=0 a=[] while(i<n): 空格 a.append(list(map(int,input().split()))) 空格 i+=1 x,y=map(int,input().split()) while(n>0): 空格if a[n-1][0]<=x<=a[n-1][0] and a[n-1][0]<=y<=a[n-1][0]: 空格 print(n) 空格 break else: 空格 n=n-1 if n==0: 空格 print(-1)