def intersection(p1, p2):
x11 = max(min(p1[0],p1[2]),min(p2[0],p2[2]))
x12 = min(max(p1[0],p1[2]),max(p2[0],p2[2]))
y11 = max(min(p1[1],p1[3]),min(p2[1],p2[3]))
y12 = min(max(p1[1],p1[3]),max(p2[1],p2[3]))
if ((x12 - x11 > 0) and (y12 - y11 > 0)):
return (x12 - x11) * (y12 - y11)
else:
return 0
n, m = map(int, input().split())
yellow = [list(map(int, input().split())) for _ in range(n)]
blue = [list(map(int, input().split())) for _ in range(m)]
res = -1
ansI = 0
ansJ = 0
for i in range(n):
for j in range(m):
inter = intersection(yellow[i], blue[j])
if res < inter:
res = inter
ansI = i
ansJ = j
print(ansI + 1, ansJ + 1)