def find_carpet(n, carpets, x, y):
for i in range(n - 1, -1, -1):
a, b, g, k = carpets[i]
if a <= x <= a + g and b <= y <= b + k:
return i + 1
return -1
n = int(input())
carpets = [list(map(int, input().split())) for _ in range(n)]
x, y = map(int, input().split())
print(find_carpet(n, carpets, x, y))