#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define ff(i,s,f) for(int i=s;i<f;i++)
#define fb(i,s,f) for(int i=(s)-1;i>=f;i--)
#define ffi(i,s,f) for(int i=s;i<=f;i++)
#define fbi(i,s,f) for(int i=s;i>=f;i--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;

const int maxn=2e5+10;

struct seg{
    vector<int> a;
    vector<int> l;
    vector<int> r;
};

int n,m;
seg segtd[4*maxn];
seg segtu[4*maxn];
int d[maxn];
int u[maxn];

void build(int *a,seg *segt,int node=1,int l=0,int r=n-1){
    if(l==r){
        segt[node].a={a[l]};
        return;
    }
    int mid=l+(r-l)/2;
    build(a,segt,2*node,l,mid);
    build(a,segt,2*node+1,mid+1,r);
    int pl=0,pr=0;
    vector<int> &vl=segt[2*node].a;
    vector<int> ml(vl.size());
    for(int i=(int)vl.size()-1;i>=0;i--){
        ml[i]=i;
        if(i<(int)vl.size()-1 && vl[i]==vl[i+1]) ml[i]=ml[i+1];
    }
    vector<int> &vr=segt[2*node+1].a;
    vector<int> mr(vr.size());
    for(int i=(int)vr.size()-1;i>=0;i--){
        mr[i]=i;
        if(i<(int)vr.size()-1 && vr[i]==vr[i+1]) mr[i]=mr[i+1];
    }
    while(pl<vl.size() || pr<vr.size()){
        if(pl==vl.size()){
            segt[node].a.push_back(vr[pr]);
            segt[node].l.push_back(int(pl)-1);
            segt[node].r.push_back(mr[pr]);
            pr++;
        }else if(pr==vr.size()){
            segt[node].a.push_back(vl[pl]);
            segt[node].l.push_back(ml[pl]);
            segt[node].r.push_back(int(pr)-1);
            pl++;
        }else{
            if(vl[pl]<=vr[pr]){
                segt[node].a.push_back(vl[pl]);
                segt[node].l.push_back(ml[pl]);
                if(vl[pl]==vr[pr]) segt[node].r.push_back(mr[pr]);
                else segt[node].r.push_back(int(pr)-1);
                pl++;
            }else{
                segt[node].a.push_back(vr[pr]);
                segt[node].l.push_back(int(pl)-1);
                segt[node].r.push_back(mr[pr]);
                pr++;
            }
        }
    }
}

int query(seg *segt,int tl,int tr,int x,int node,int l=0,int r=n-1){
    if(tl<=l && r<=tr){
        return x+1;
    }
    int mid=l+(r-l)/2;
    int ret=0;
    if(tl<=mid) ret+=query(segt,tl,tr,(x!=-1 ? segt[node].l[x]:-1),2*node,l,mid);
    if(tr>mid) ret+=query(segt,tl,tr,(x!=-1 ? segt[node].r[x]:-1),2*node+1,mid+1,r);
    return ret;
}

int query(seg *segt,int l,int r,int x){
    int poz=upper_bound(segt[1].a.begin(),segt[1].a.end(),x)-segt[1].a.begin()-1;
    return query(segt,l,r,poz,1);
}

void solve(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>d[i]>>u[i];
    }
    build(d,segtd);
    build(u,segtu);
    while(m--){
        int l,r,x;
        cin>>l>>r>>x;
        l--; r--;
        cout<<query(segtd,l,r,x)-query(segtu,l,r,x-1)<<"\n";
    }
}

int main(){
    ios;
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}