#include<bits/stdc++.h>



using namespace std;

struct w
{
    int x,l,r,d;
    
    bool operator<(w b){
        return x<b.x||( x==b.x && b.d!=-1 );
    }
};



int fenwickq(int* fen, int r){
    int res = 0;
    while (r >= 0){
        res += fen[r];
        r = (r & (r+1))-1;
    }
    return res;
}

void fenwickADD(int* fen, int r, int n){
    for(;r < n ;r = r| (r+1))
        fen[r] += 1;
}




void findLower(int* fen, int* out, vector<w> &a, int n,int m){
    for(int i =0; i<n+m;i++){
        if(a[i].d==-1){
            fenwickADD(fen,a[i].l,n);
        }
        else{
            out[a[i].d] = fenwickq(fen,a[i].r)-fenwickq(fen,a[i].l-1);
        }
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<w> up(n+m);
    vector<w> low(n+m);
    for(int i=0;i<n;i++){
        cin >> low[i].x >> up[i].x;
        low[i].d=up[i].d=-1;
        low[i].l=i;
        up[i].l=i;
        low[i].r=-1;
        up[i].r=-1;
    }
    for(int i=n;i<n+m;i++){
        cin >> low[i].l >> low[i].r >> low[i].x;
        low[i].d = up[i].d = i-n;
        up[i].x=low[i].x-1;

        low[i].l--;
        low[i].r--;
        
        up[i].l=low[i].l;
        up[i].r=low[i].r;
    }
    sort(up.begin(),up.end());
    sort(low.begin(),low.end());
    int fen1[n] = {};
    int fen2[n] = {};
    
    int res[m] = {};
    int negres[m] = {};

    findLower(fen1,res,low,n,m);
    findLower(fen2,negres,up,n,m);

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

    }    
    
    return 0;
}