#include <iostream>
#include <vector>
using namespace std;
int main() {
long n, m;
cin >> n >> m;
long a[n][4];
long b[m][2];
for(long i = 0; i < n; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
for(long i = 0; i < m; i++)
cin >> b[i][0] >> b[i][1];
long k =0;
vector<bool> vec(m, true);
for(long i = 0; i < m; i++)
{
for(long j = 0; j < n; j++)
{
if((b[i][0] >= a[j][0] && b[i][1] >= a[j][1]) && ( b[i][0] <= a[j][2] && b[i][1] <= a[j][3]) && vec[j])
{
cout << j + 1 << " ";
vec[j] = false;
k = 1;
break;
}
k = 0;
}
if(k == 0)
cout << "-1 ";
}
return 0;
}