#include<bits/stdc++.h>

using namespace std;
long long int typedef li;

const int mx=1'000'000'000;

int N;
int fwt[600005];

void add(int i, int x)
{
    for (;i<=N;i+=(i&-i)) fwt[i]+=x;
}

int pre(int i)
{
    int res=0;
    for (;i;i-=(i&-i)) res+=fwt[i];
    return res;
}

vector<pair<int,int>> segs(1);
vector<int> lls(1);
vector<int> rrs(1);
vector<int> xs(1);
vector<pair<int,int>> pos[200005];
vector<pair<int,int>> neg[200005];

int ans[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    vector<pair<int,pair<int,int>>> komp;

    int n,q; cin>>n>>q;
    for (int i=1;i<=n;i++)
    {
        int ll,rr; cin>>ll>>rr;
        segs.push_back({ll,rr});
        komp.push_back({ll,{1,i}});
        komp.push_back({rr,{2,i}});
    }

    for (int i=1;i<=q;i++)
    {
        int ll,rr,x; cin>>ll>>rr>>x;
        lls.push_back(ll);
        rrs.push_back(rr);
        xs.push_back(x);
        komp.push_back({x,{3,i}});
    }

    sort(komp.begin(),komp.end());
    int br=1;

    if (komp[0].second.first==1) segs[komp[0].second.second].first=br;
    else if (komp[0].second.first==2) segs[komp[0].second.second].second=br;
    else if (komp[0].second.first==3) xs[komp[0].second.second]=br;

    for (int i=1;i<komp.size();i++)
    {
        if (komp[i].first!=komp[i-1].first) br++;

        if (komp[i].second.first==1) segs[komp[i].second.second].first=br;
        else if (komp[i].second.first==2) segs[komp[i].second.second].second=br;
        else if (komp[i].second.first==3) xs[komp[i].second.second]=br;
    }

    N=br;

    for (int i=1;i<=q;i++)
    {
        neg[lls[i]-1].push_back({xs[i],i});
        pos[rrs[i]].push_back({xs[i],i});
    }

    for (int i=1;i<=n;i++)
    {
        int ll=segs[i].first,rr=segs[i].second;
        add(ll,1),add(rr+1,-1);

        for (auto it : pos[i]) ans[it.second]+=pre(it.first);
        for (auto it : neg[i]) ans[it.second]-=pre(it.first);
    }

    for (int i=1;i<=q;i++) cout<<ans[i]<<"\n";
}