#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb emplace_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {
	os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T,class U> ostream& operator<<(ostream &os, const tuple<S,T,U> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class S, class T,class U,class V> ostream& operator<<(ostream &os, const tuple<S,T,U,V> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<","<<get<3>(t)<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
#else
#define out
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7;

template<int N>
struct FID {
  using Bits = uint32_t;
  static const int B = 8*sizeof(Bits);
  int n;
  int buck[N/B+2];
  Bits bits[N/B+2];
  int sel[2][N];

  FID() {}
  FID(int n, bool bs[]) : n(n) {
    int cnt = 0;
    int idx = 0;
    fill(buck, buck+N/B+2, 0);
    fill(bits, bits+N/B+2, 0);
    rep(i, n/B + (n%B != 0)) {
      rep(j, B) {
        if (idx >= n) break;
        cnt += bs[idx];
        bits[i] |= Bits(bs[idx]) << j;
        idx++;
      }
      buck[i+1] = cnt;
    }

    fill(sel[0], sel[2], -1);
    cnt = 0;
    rep(i, n) {
      if (bs[i]) {
        sel[1][cnt] = i;
        cnt++;
      } else {
        sel[0][i-cnt] = i;
      }
    }
  }

  int Count(bool v, int r) {
    int ret = buck[r/B] + __builtin_popcount(bits[r/B] % (1<<(r%B)));
    if (!v) ret = r - ret;
    return ret;
  }

  int Select(bool v, int k) {
    if (k < 0 || k >= n) return -1;
    return sel[v][k];
  }

  int SelectFrom(int from, bool v, int k) {
    return Select(v, Count(v, from) + k);
  }

  bool operator[](int k) {
    return bits[k/B] >> (k%B) & 1;
  }
};

template<int N, class T=unsigned int>          
struct Wavelet {
  static const int D = 8*sizeof(T);
  int n;
  int sep[D];
  FID<N> dat[D];
  T arr[N];

  Wavelet(int n, T ini[]) : n(n) {
    T l[N];
    T r[N];
    T src[N];
    bool bs[N];

    copy(ini, ini+n, arr);
    copy(ini, ini+n, src);
    rep (d, D) {
      int rk = 0;
      int lk = 0;
      rep(i, n) {
        bool t = src[i] >> (D-d-1) & 1;
        if (t) r[rk++] = src[i];
        else l[lk++] = src[i];
        bs[i] = t;
      }
      dat[d] = FID<N>(n, bs);
      sep[d] = lk;
      swap(l, src);
      copy(r, r+rk, src+lk);
    }
  }

  int Count(T val, int l, int r) {
    if (r <= l) return 0;
    rep(d, D) {
      bool b = val >> (D-d-1) & 1;
      l = dat[d].count(b, l) + b*sep[b];
      r = dat[d].count(b, r) + b*sep[b];
    }
    return r-l;
  }

  int Select(T val, int k) {
    int ls[D+1];
    int rs[D+1];
    ls[0] = 0;
    rs[0] = n;
    rep(d, D) {
      bool b = val >> (D-d-1) & 1;
      ls[d+1] = dat[d].count(b, ls[d]) + b*sep[b];
      rs[d+1] = dat[d].count(b, rs[d]) + b*sep[b];
    }
    rrep(d, D) {
      bool b = val >> (D-d-1) & 1;
      k = dat[d].SelectFrom(ls[d], b, k);
      if (k < 0 || k >= rs[d]) return -1;
      k -= ls[d];
    }
    return k;
  }

  T KthNumber(int l, int r, int k) {
    if (k < 0 || k >= r-l) assert(0);
    T ret = 0;
    rep(d, D) {
      int lc = dat[d].Count(1, l);
      int rc = dat[d].Count(1, r);
      if (rc - lc > k) {
        l = lc + sep[d];
        r = rc + sep[d];
        ret |= T(1) << (D-d-1);
      } else {
        k -= rc-lc;
        l -= lc;
        r -= rc;
      }
    }
    return ret;
  }

  int FreqDfs(int d, int l, int r, T val, T a, T b) {
    if (r <= l) return 0;
    if (d == D) {
      if (a <= val && val < b) return r-l;
      return 0;
    }

    T h = T(1) << (D-d-1);
    T nv = val | h; 
    T lim = nv | (h-1);
    if (lim < a || b <= val) return 0;
    if (a <= val && lim < b) return r-l;

    int lc = dat[d].Count(1, l);
    int rc = dat[d].Count(1, r);
    int lval = FreqDfs(d+1, l-lc, r-rc, val, a, b);
    int rval = FreqDfs(d+1, lc+sep[d], rc+sep[d], nv, a, b);
    return lval + rval;
  }

  int Freq(int l, int r, T a, T b) {
    return FreqDfs(0, l, r, 0, a, b);
  }

  T operator[](int k) {
    return arr[k];
  }
};

const int GETA = 1e9;
int N;
int M;
unsigned int ys[114514];
vector<PII> ps;

int main() {
  scanf("%d%d", &N, &M);
  rep(i, N) {
    int x, y;
    scanf("%d%d", &x, &y);
    y += GETA;
    ps.emplace_back(PII(x, y));
  }
  sort(all(ps));
 
  rep(i, N) ys[i] = ps[i].second;
  Wavelet<5000> wave(N, ys);

  rep(i, M) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    b += GETA;
    d += GETA;
    int x = lower_bound(all(ps), PII(a, 0)) - ps.begin();
    int y = upper_bound(all(ps), PII(c, GETA*2)) - ps.begin();
    printf("%d\n", wave.Freq(x, y, b, d+1));
  }
}



Measured memory_bytes: 4840