// AOJ 2426 Treasure Hunt
// (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2426)
// 座標圧縮＆2次元累積和
// nとmを両方圧縮しようとして失敗
// テーブル作成時に最大O(m^2)でメモリオーバー
// nだけでテーブルを作成して、mのマッピングが欲しい

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pii = pair<ll, ll>;

struct rect {
  ll x1, y1, x2, y2;
};

int main(int argc, char const* argv[]) {
  ll n, m;
  cin >> n >> m;  // n < 5000, m < 5e5
  priority_queue<ll, vi, std::greater<ll>> x_sorted, y_sorted;  // asc
  // treasure
  vector<pii> ts = vector<pii>(n, make_pair(0, 0));
  for (auto&& p : ts) {
    cin >> p.first >> p.second;
    x_sorted.push(p.first);
    y_sorted.push(p.second);
  }
  /*
    vector<struct rect*> rs;
    for (int i = 0; i < m; i++) {
      struct rect* r = new struct rect;
      cin >> r->x1 >> r->y1 >> r->x2 >> r->y2;
      rs.push_back(r);
      x_sorted.push(r->x1);
      x_sorted.push(r->x2);
      y_sorted.push(r->y1);
      y_sorted.push(r->y2);
    }
  */

  ll x_max = -1, y_max = -1;
  unordered_map<ll, ll> x_mapping, y_mapping;
  vi x_v, y_v;
  // x mappingの作成
  // cerr << "x mapping" << endl;
  for (ll i = 0, prev = -1e10; !x_sorted.empty(); x_sorted.pop()) {
    if (prev == x_sorted.top())
      continue;
    else
      prev = x_sorted.top();

    x_mapping[x_sorted.top()] = i;
    x_v.push_back(x_sorted.top());
    // cerr << i << ":" << x_sorted.top() << "\t";
    x_max = i++;
  }
  x_v.push_back(1e10);
  x_max++;
  // cerr << endl;

  // y mappingの作成
  // cerr << "y mapping" << endl;
  for (ll i = 0, prev = -1e10; !y_sorted.empty(); y_sorted.pop()) {
    if (prev == y_sorted.top())
      continue;
    else
      prev = y_sorted.top();

    y_mapping[y_sorted.top()] = i;
    y_v.push_back(y_sorted.top());
    // cerr << i << ":" << y_sorted.top() << '\t';
    y_max = i++;
  }
  y_v.push_back(1e10);
  y_max++;
  // cerr << endl;

  vvi tbl = vvi(x_max + 1, vi(y_max + 1, 0));
  for (int i = 0; i < n; i++) {
    pii p = ts[i];
    ll xx = x_mapping[p.first];
    ll yy = y_mapping[p.second];
    tbl[xx][yy]++;
    // fprintf(stderr, "[%d][%d] ++\n", xx, yy);
  }

  // for (int i = 0; i <= x_max; i++) {
  // for (int j = 0; j <= y_max; j++) {
  // cerr << tbl[i][j] << " \t";
  // }
  // cerr << endl;
  // }
  // 2次元累積和
  // 各座標の値を累積和で上書きして2つ目のテーブルを確保せずに実装している。
  for (int i = 0; i <= x_max; i++) {
    for (int j = 0; j <= y_max; j++) {
      if (i > 0) tbl[i][j] += tbl[i - 1][j];
      if (j > 0) tbl[i][j] += tbl[i][j - 1];
      if (i > 0 && j > 0) tbl[i][j] -= tbl[i - 1][j - 1];
      // cerr << tbl[i][j] << " \t";
    }
    // cerr << endl;
  }

  for (int i = 0; i < m; i++) {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    // fprintf(stderr, "(%lld,%lld,%lld,%lld) -> ", x1, y1, x2, y2);
    auto x1i = lower_bound(x_v.begin(), x_v.end(), x1);
    x1 = x1i - x_v.begin();
    auto y1i = lower_bound(y_v.begin(), y_v.end(), y1);
    y1 = y1i - y_v.begin();

    auto x2i = upper_bound(x_v.begin(), x_v.end(), x2);
    x2 = (x2i - x_v.begin()) - 1;
    auto y2i = upper_bound(y_v.begin(), y_v.end(), y2);
    y2 = (y2i - y_v.begin()) - 1;
    // fprintf(stderr, "(%lld,%lld,%lld,%lld)\n", x1, y1, x2, y2);
    // x_v,y_vからピックアップ
    // ll x1 = x_mapping[rs[i]->x1];
    // ll x2 = x_mapping[rs[i]->x2];
    // ll y1 = y_mapping[rs[i]->y1];
    // ll y2 = y_mapping[rs[i]->y2];
    if (x2 < 0 || y2 < 0) {
      cout << 0 << endl;
      continue;
    }

    ll ret = tbl[x2][y2];
    // cerr << ret << ",";
    if (x1 > 0) ret -= tbl[x1 - 1][y2];
    // cerr << ret << ",";
    if (y1 > 0) ret -= tbl[x2][y1 - 1];
    // cerr << ret << ",";
    if (x1 > 0 && y1 > 0) ret += tbl[x1 - 1][y1 - 1];
    // cerr << ret << ",";

    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 199320