#include <bits/stdc++.h>
using namespace std;
long long intersection(vector<long long> p1, vector<long long> p2)
{
long long x11 = max(min(p1[0],p1[2]),min(p2[0],p2[2]));
long long x12 = min(max(p1[0],p1[2]),max(p2[0],p2[2]));
long long y11 = max(min(p1[1],p1[3]),min(p2[1],p2[3]));
long long y12 = min(max(p1[1],p1[3]),max(p2[1],p2[3]));
if ((x12 - x11 > 0) && (y12 - y11 > 0))
return (x12 - x11) * (y12 - y11);
else
return 0;
}
vector<vector<long long> > yellow(1000);
vector<vector<long long> > blue(1000);
int main()
{
int n,m;
cin >> n >> m;
for (int i = 0; i<n; ++i)
{
long long a;
for (int j = 0; j<4; ++j)
{
cin >> a;
yellow[i].push_back(a);
}
}
for (int i = 0; i<m; ++i)
{
long long a;
for (int j = 0; j<4; ++j)
{
cin >> a;
blue[i].push_back(a);
}
}
long long res = -1;
int ansi = 0, ansj = 0;
for (int i = 0; i<n; ++i)
{
for (int j = 0; j<m; ++j)
{
long long inter = intersection(yellow[i], blue[j]);
if (res<inter)
{
res = inter;
ansi = i;
ansj = j;
}
}
}
cout << ansi+1 << ' ' << ansj+1 << endl;
return 0;
}