#include <bits/stdc++.h>
#define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) (a).begin(), (a).end()
#define mp make_pair 
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
*/
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element                                          

void files() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

const double eps = 0.00000001;
const ll NMAX = 200010;
const ll inf = 1e16;
const ll modi = 1e9+7;

vector<pii>al[NMAX];
int res[NMAX];

ll seg[NMAX*4];
void update(int s, int val, int nl = 0, int nr = NMAX, int node = 0) {
    if ( nl == nr && nl ==s ) {
        seg[node] += val;
        return;
    }
    if ( nr < s || nl > s ) return;
    int mid = nl+nr;
    mid/=2;
    update(s,val,nl,mid,node*2+1);
    update(s,val,mid+1,nr,node*2+2);
    seg[node] = seg[node*2+1] + seg[node*2+2];
}
 
ll rmq(int sl, int sr, int nl = 0, int nr = NMAX, int node = 0) {
    if ( nl>=sl && nr<=sr ) {
        return seg[node];
    }
    if ( nr < sl || nl > sr ) return 0;
    int mid = nl+nr;
    mid/=2;
    return rmq(sl,sr,nl,mid,node*2+1) + rmq(sl,sr,mid+1,nr,node*2+2);
}

void solve() {
    int n,m;
    cin >> n >> m;

    vector<vector<int>>v;
    vector<vector<int>>qu;
    for (int i = 0 ; i < n ; i++ ) {
        int a,b;
        cin >> a >> b;
        v.pb({a  ,i, 1});
        v.pb({b+1,i,-1});
    }

    sort(all(v));
    int ii = 0;

    for (int i = 0 ; i < m ; i++ ) {
        int l,r,x;
        cin >> l >> r >> x;
        qu.pb({x,i,l-1,r-1});
    }

    sort(all(qu));

    for (int i = 0 ; i < m ; i++ ) {
        int x = qu[i][0];
        int ind = qu[i][1];
        int l = qu[i][2];
        int r = qu[i][3];
        //cout << x << ' ' << ind << "#" << endl;
        while(ii<2*n && v[ii][0] <= x) {
            //cout <<v[ii][1]<< ' '<<v[ii][2]<< endl; 
            update(v[ii][1],v[ii][2]);
            ii++;
        }

        //cout << x << ' ' << ind << ' ' << l << ' ' << r << endl;
        res[ind] = rmq(l,r);
        //cout << "#" << endl;
    }

    for (int i = 0 ; i < m ; i++ ) {
        cout << res[i] << endl;
    }

}

int main () { 
    FAST
    int t=1;

    /*
    cin >> t;
    //*/

    int i = 1;
    while(t--) {
        //cout << "Case #" << i++ << ": " ;
        solve();
    }
}