#include <bits/stdc++.h>

using namespace std;

int n,q,L[200010],R[200010],b1,b2,b3;
vector<pair<int,pair<int,int>>> V[800010];

void napravi_segmentno(int x,int l,int r)
{
    V[x].push_back({0,{0,0}});
    if(l==r)
    {
        V[x].push_back({L[l],{1,1}});
        V[x].push_back({R[l],{-1,0}});
        return;
    }
    int s = (l+r)/2;
    napravi_segmentno(x*2,l,s);
    napravi_segmentno(x*2+1,s+1,r);
    int b1=1,b2=1;
    while(b1<V[x*2].size() || b2<V[x*2+1].size())
    {
        if(b1==V[x*2].size())
        {
            V[x].push_back(V[x*2+1][b2]);
            b2++;
            V[x][V[x].size()-1].second.second = V[x][V[x].size()-2].second.second + V[x][V[x].size()-1].second.first;
            continue;
        }
        if(b2==V[x*2+1].size())
        {
            V[x].push_back(V[x*2][b1]);
            b1++;
            V[x][V[x].size()-1].second.second = V[x][V[x].size()-2].second.second + V[x][V[x].size()-1].second.first;
            continue;
        }
        if(V[x*2][b1].first<V[x*2+1][b2].first)
        {
            V[x].push_back(V[x*2][b1]);
            b1++;
        }
        else
        {
            V[x].push_back(V[x*2+1][b2]);
            b2++;
        }
        V[x][V[x].size()-1].second.second = V[x][V[x].size()-2].second.second + V[x][V[x].size()-1].second.first;
    }
}

int prebroj_segmentno(int x,int v)
{
    int l,r,s;
    l = 0;
    r = V[x].size();
    while(l+1<r)
    {
        s = (l+r)/2;
        if(V[x][s].first<=v) l = s;
        else r = s;
    }
    return V[x][l].second.second;
}

int nadji_segmentno(int x,int l,int r,int ll,int rr,int v)
{
    if(rr<l || r<ll) return 0;
    if(ll<=l && r<=rr)
    {
        return prebroj_segmentno(x,v);
    }
    int s = (l+r)/2;
    return nadji_segmentno(x*2,l,s,ll,rr,v) + nadji_segmentno(x*2+1,s+1,r,ll,rr,v);
}

int main()
{
    scanf("%d %d",&n,&q);
    for(int i=1; i<=n; i++)
    {
        scanf("%d %d",&L[i],&R[i]);
        R[i]++;
    }
    napravi_segmentno(1,1,n);
    while(q--)
    {
        scanf("%d %d %d",&b1,&b2,&b3);
        printf("%d\n",nadji_segmentno(1,1,n,b1,b2,b3));
    }
    return 0;
}