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

const int INF = 2000000000;

const int MAXN = 200002;
int t[4 * MAXN];
 

int get(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (l == tl && r == tr)
        return t[v];

    int tm = (tl + tr) / 2;
    //cout << tl << " " << tr << " " << l << " " << r << endl;
    return get(v*2, tl, tm, l, min(r, tm)) + 
            get(v*2+1, tm+1, tr, max(l, tm+1), r);
}

void update(int v, int tl, int tr, int pos, int x) {
    if (tl == tr) {
        t[v] = x;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) {
            update(v*2, tl, tm, pos, x);
        }
        else {
            update(v*2+1, tm+1, tr, pos, x);
        }
        t[v] = t[v*2] + t[v*2+1];
    }
}


int main(int argc, char **argv){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    vector<pair<pair<int, int>, int>> vec(n+1);
    for(int i = 1; i <= n; i++) {
    	int d, u;
    	cin >> d >> u;

    	vec[i].first = {u, d};
        vec[i].second = i;
    }
    sort(vec.begin(), vec.end(), greater<>());

    for(int i = 0; i < n; i++) {
       // cout << vec[i].first.first << " " << vec[i].first.second << " " << vec[i].second << endl;
    }
    //cout << endl;

    vector<pair<int, pair<pair<int, int>, int>>> queues(m);
    for(int i = 0; i < m; i++) {
        int l, d, x;
        cin >> l >> d >> x;
        queues[i].first = x;
        queues[i].second.first = {l, d};
        queues[i].second.second = i;
    }

    sort(queues.begin(), queues.end(), greater<>());

    for(int i = 0; i < m; i++) {
        //cout << queues[i].first << " " << queues[i].second.first.first << " " << queues[i].second.first.second << endl;
    }
    //cout << endl;

    int j = 0;

    priority_queue<pair<int, int>> q;

    vector<int> ans(m);

    for(int i = 0; i < m; i++){
        while(j < n && vec[j].first.first >= queues[i].first){
            //cout << "added: " << vec[j].first.first << " " << vec[j].first.second << " " << vec[j].second << endl;
            update(1, 1, n, vec[j].second, 1);
            q.push({vec[j].first.second, vec[j].second});
            j++;
        }
        while(!q.empty() && (q.top().first > queues[i].first)) {
            //cout << "Removed: " << -q.top().first << endl;
            update(1, 1, n, q.top().second, 0);
            q.pop();
        }
        //cout << "------" << endl;
       ans[queues[i].second.second] = get(1, 1, n, queues[i].second.first.first, queues[i].second.first.second);
    }

    for(int i = 0; i < m; i++) {
        cout << ans[i] << '\n';
    }

   
    return 0;
}