#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

tiii xso[5010];
tiii yso[5010];
int tre[2][5010];
int bo[5010][5010];

int main() {
    int n, m;
    cin >> n >> m;
    tre[0][0] = intmin;
    tre[1][0] = intmin;
    tre[0][n + 1] = intmax;
    tre[1][n + 1] = intmax;
    for (int i = 0; i < n; i++) {
        cin >> tre[0][i + 1] >> tre[1][i + 1];
        xso[i] = make_tuple(tre[0][i + 1], i + 1, 0);
        yso[i] = make_tuple(tre[1][i + 1], i + 1, 0);
    }
    sort(tre[0], tre[0] + n + 1);
    sort(tre[1], tre[1] + n + 1);
    sort(xso, xso + n);
    sort(yso, yso + n);
    for (int i = 0; i < n; i++) {
        tiii xt = xso[i];
        tiii yt = yso[i];
        xso[i] = make_tuple(get<1>(xt), get<0>(xt), i + 1);
        yso[i] = make_tuple(get<1>(yt), get<0>(yt), i + 1);
    }
    sort(xso, xso + n);
    sort(yso, yso + n);
    for (int i = 0; i < n + 10; i++) {
        fill(bo[i], bo[i] + n + 10, 0);
    }
    for (int i = 0; i < n; i++) {
        int x = get<2>(xso[i]);
        int y = get<2>(yso[i]);
        bo[x][y]++;
    }
    for (int i = 0; i < n + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            bo[i][j] = bo[i][j] + bo[i][j - 1];
        }
    }
    for (int i = 0; i < n + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            bo[j][i] = bo[j][i] + bo[j - 1][i];
        }
    }
    // for (int i = 0; i < n + 1; i++) {
    //     for (int j = 0; j < n + 1; j++) {
    //         cout << bo[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // for (int i = 0; i < n + 1; i++) {
    //     cout << tre[0][i] << " ";
    // }
    // cout << endl;
    // for (int i = 0; i < n + 1; i++) {
    //     cout << tre[1][i] << " ";
    // }
    // cout << endl;
    for (int i = 0; i < m; i++) {
        int xy[4];
        cin >> xy[0] >> xy[1] >> xy[2] >> xy[3];
        int xy2[4];
        for (int j = 2; j < 4; j++) {
            int l = 0;
            int r = n + 1;
            while (r - l > 1) {
                int now = (l + r) / 2;
                if (tre[j % 2][now] <= xy[j]) {
                    l = now;
                } else {
                    r = now;
                }
            }
            xy2[j] = r;
        }
        for (int j = 0; j < 2; j++) {
            int l = 0;
            int r = n + 1;
            while (r - l > 1) {
                int now = (l + r) / 2;
                if (tre[j % 2][now] < xy[j]) {
                    l = now;
                } else {
                    r = now;
                }
            }
            xy2[j] = r;
        }
        int xa = xy2[0];
        int ya = xy2[1];
        int xb = xy2[2];
        int yb = xy2[3];
        int ans = bo[xb - 1][yb - 1] - bo[xa - 1][yb - 1]
            - bo[xb - 1][ya - 1] + bo[xa - 1][ya - 1];
        //cout << xa << " " << ya << " " << xb << " " << yb << endl;
        cout << ans << endl;
    }
}



Measured memory_bytes: 101304