#include <bits/stdc++.h>
#define ll long long
#define mp(x,y) make_pair(x,y)

using namespace std;


vector<pair<int,pair<int,int>>> seg[800005];
vector<pair<int,int>> a;


void gen(int l, int r, int ind)
{
    //cout<<ind<<endl;
    if(l==r)
    {
        seg[ind].push_back(mp(a[l].first,mp(1,1)));
        seg[ind].push_back(mp(a[l].second+1,mp(0,-1)));
        return;
    }
    //cout<<ind<<endl;
    gen(l, (l+r)/2, 2*ind+1);
    gen((l+r)/2+1, r, 2*ind+2);
    //cout<<ind<<endl;
    int i=0,j=0,sum=0;
    while(i<seg[2*ind+1].size() || j<seg[2*ind+2].size())
    {
        if(i>=seg[2*ind+1].size())
        {
            int aux=seg[2*ind+2][j].second.second;
            sum+=aux;
            seg[ind].push_back(mp(seg[2*ind+2][j].first,mp(sum,aux)));
            j++;
        }
        else if(j>=seg[2*ind+2].size())
        {
            int aux=seg[2*ind+1][i].second.second;
            sum+=aux;
            seg[ind].push_back(mp(seg[2*ind+1][i].first,mp(sum,aux)));
            i++;
        }
        else
        {
            if(seg[2*ind+1][i].first < seg[2*ind+2][j].first)
            {
                int aux=seg[2*ind+1][i].second.second;
                sum+=aux;
                seg[ind].push_back(mp(seg[2*ind+1][i].first,mp(sum,aux)));
                i++;

            }
            else
            {
                int aux=seg[2*ind+2][j].second.second;
                sum+=aux;
                seg[ind].push_back(mp(seg[2*ind+2][j].first,mp(sum,aux)));
                j++;

            }
        }

    }


}

int bin(int ind, int x, int l, int r)
{
    if(l==r)return l;
    int mid=(l+r+1)/2;
    if(seg[ind][mid].first<=x)return bin(ind,x,mid,r);
    return bin(ind,x,l,mid-1);


}

int resi(int x, int l, int r, int ind, int ln, int rn)
{
    if((r<ln && l<ln) ||(r>rn && l>rn))return 0;
    if(r>=rn && l<=ln)
    {
        int up = bin(ind, x, -1,seg[ind].size()-1);
        if(up==-1)return 0;
        return seg[ind][up].second.first;
    }

    return resi(x,l,r,2*ind+1,ln,(ln+rn)/2)+ resi(x,l,r,2*ind+2,(ln+rn)/2+1,rn);

}



int main()
{
    int n,m;

    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++)
    {
        int u,d;
        scanf("%d %d",&d,&u);
        a.push_back(mp(d,u));
    }
    gen(0,n-1,0);


    for(int i=0; i<m; i++)
    {
        int l,r,x;
        scanf("%d %d %d", &l,&r,&x);
        int rez=resi(x,l-1,r-1,0,0,n-1);
        printf("%d\n",rez);

    }





    return 0;
}