#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct rectangle {
int xmin, ymin, xmax, ymax;
};
bool in(rectangle a, int x, int y) {
return x >= a.xmin && x <= a.xmax && y >= a.ymin && y <= a.ymax;
}
bool sort_cmp(rectangle a, rectangle b) {
if (a.xmin != b.xmin) return a.xmin < b.xmin;
else return a.ymin < b.ymin;
}
int bs(vector<rectangle> a, int x, int y) {
if (a.empty()) return -1;
int l = 0, r = (int) a.size();
int result = -1;
while (l <= r) {
int mid = (l + r) / 2;
if (x < a[mid].xmin || y < a[mid].ymin) {
r = mid - 1;
} else if (x > a[mid].xmax || y > a[mid].ymax) {
l = mid + 1;
} else {
result = mid;
r = mid - 1;
}
}
return result;
}
int main() {
int n, m, x, y;
cin >> n >> m;
vector<rectangle> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].xmin >> a[i].xmax >> a[i].ymin >> a[i].ymax;
}
sort(a.begin(), a.end(), sort_cmp);
for (int i = 0; i < m; i++) {
cin >> x >> y;
vector<rectangle> aux;
int j = bs(a, x, y);
if (j != -1) {
while (j < a.size()) {
if (in(a[j], x, y)) {
aux.push_back(a[j++]);
} else break;
}
}
cout << aux.size() << " ";
a = aux;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCByZWN0YW5nbGUgewogICAgaW50IHhtaW4sIHltaW4sIHhtYXgsIHltYXg7Cn07Cgpib29sIGluKHJlY3RhbmdsZSBhLCBpbnQgeCwgaW50IHkpIHsKICAgIHJldHVybiB4ID49IGEueG1pbiAmJiB4IDw9IGEueG1heCAmJiB5ID49IGEueW1pbiAmJiB5IDw9IGEueW1heDsKfQoKYm9vbCBzb3J0X2NtcChyZWN0YW5nbGUgYSwgcmVjdGFuZ2xlIGIpIHsKICAgIGlmIChhLnhtaW4gIT0gYi54bWluKSByZXR1cm4gYS54bWluIDwgYi54bWluOwogICAgZWxzZSByZXR1cm4gYS55bWluIDwgYi55bWluOwp9CgppbnQgYnModmVjdG9yPHJlY3RhbmdsZT4gYSwgaW50IHgsIGludCB5KSB7CiAgICBpZiAoYS5lbXB0eSgpKSByZXR1cm4gLTE7CgogICAgaW50IGwgPSAwLCByID0gKGludCkgYS5zaXplKCk7CiAgICBpbnQgcmVzdWx0ID0gLTE7CgogICAgd2hpbGUgKGwgPD0gcikgewogICAgICAgIGludCBtaWQgPSAobCArIHIpIC8gMjsKICAgICAgICBpZiAoeCA8IGFbbWlkXS54bWluIHx8IHkgPCBhW21pZF0ueW1pbikgewogICAgICAgICAgICByID0gbWlkIC0gMTsKICAgICAgICB9IGVsc2UgaWYgKHggPiBhW21pZF0ueG1heCB8fCB5ID4gYVttaWRdLnltYXgpIHsKICAgICAgICAgICAgbCA9IG1pZCArIDE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmVzdWx0ID0gbWlkOwogICAgICAgICAgICByID0gbWlkIC0gMTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0Owp9CgppbnQgbWFpbigpIHsKCiAgICBpbnQgbiwgbSwgeCwgeTsKCiAgICBjaW4gPj4gbiA+PiBtOwoKICAgIHZlY3RvcjxyZWN0YW5nbGU+IGEobik7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gYVtpXS54bWluID4+IGFbaV0ueG1heCA+PiBhW2ldLnltaW4gPj4gYVtpXS55bWF4OwogICAgfQoKICAgIHNvcnQoYS5iZWdpbigpLCBhLmVuZCgpLCBzb3J0X2NtcCk7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBtOyBpKyspIHsKICAgICAgICBjaW4gPj4geCA+PiB5OwoKICAgICAgICB2ZWN0b3I8cmVjdGFuZ2xlPiBhdXg7CgogICAgICAgIGludCBqID0gYnMoYSwgeCwgeSk7CgogICAgICAgIGlmIChqICE9IC0xKSB7CiAgICAgICAgICAgIHdoaWxlIChqIDwgYS5zaXplKCkpIHsKICAgICAgICAgICAgICAgIGlmIChpbihhW2pdLCB4LCB5KSkgewogICAgICAgICAgICAgICAgICAgIGF1eC5wdXNoX2JhY2soYVtqKytdKTsKICAgICAgICAgICAgICAgIH0gZWxzZSBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgY291dCA8PCBhdXguc2l6ZSgpIDw8ICIgIjsKCiAgICAgICAgYSA9IGF1eDsKICAgIH0KCn0K