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

const int INF = 2000000000;

const int MAXN = 200002;
pair<int, int> t[4 * MAXN];

pair<int, int> combine(pair<int, int> a, pair<int, int> b) {
    return make_pair(min(a.first, b.first), max(a.second, b.second));
}

void build(vector<pair<int, int>>& vec, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = vec[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(vec, v*2, tl, tm);
        build(vec, v*2+1, tm+1, tr);
        t[v] = combine(t[v*2], t[v*2+1]);
    }
}

int get(int v, int tl, int tr, int l, int r, int x) {
    if (l > r)
        return 0;
    if(t[v].first > x || t[v].second < x) return 0;
    if (l == tl && r == tr && l == r) {
        return 1;
    }
    int tm = (tl + tr) / 2; 
    return get(v*2, tl, tm, l, min(r, tm), x) + get(v*2+1, tm+1, tr, max(l, tm+1), r, x);
}


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<int, int>> vec(n+1);
    for(int i = 1; i <= n; i++) {
    	int d, u;
    	cin >> d >> u;

    	vec[i] = {d, u};
    }

    build(vec, 1, 1, n);
   //for(int i = 0; i <= 2 * n - 1; i++){
   //    cout << t[i].first << " " << t[i].second << endl;
   //}

    for(int i = 0; i < m; i++){
        int l, d, x;
        cin >> l >> d >> x;
        cout << get(1, 1, n, l, d, x) << endl;
    }
    
    return 0;
}