#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

#define pb push_back
#define MAXN 200010
#define pii pair<int, int>
#define xx first
#define yy second

using namespace std;

int n, m, u[MAXN], d[MAXN], l[MAXN], r[MAXN], x[MAXN];
vector<int> svi;
vector<pii> red;
int cnt=1;
map<int, int> f;
vector<int> ress[MAXN];
int bit[4*MAXN];

void upd(int x,int s)
{
    while(x<MAXN)
    {
        bit[x]+=s;
        x+=x&(-x);
    }
}
int sum(int x)
{
    int v=0;
    while(x)
    {
        v+=bit[x];
        x-=x&(-x);
    }
    return v;
}

int main() {
    cin>>n>>m;

    for (int i=1; i<=n; i++)
    {
        cin>>u[i]>>d[i]; svi.pb(u[i]); svi.pb(d[i]);
        red.pb({i, 0});
    }
    for (int i=1; i<=m; i++) { cin>>l[i]>>r[i]>>x[i]; red.pb({l[i]-1, i}); red.pb({r[i], i}); svi.pb(x[i]); }

    sort(svi.begin(), svi.end());
    for (int i=0; i<svi.size(); i++)
    {
        if (i!=0 && svi[i]!=svi[i-1])
            cnt++;
        f[svi[i]]=cnt;
        //cout<<svi[i]<<" je "<<f[svi[i]]<<endl;
    }

    for (int i=1; i<=n; i++) { u[i]=f[u[i]]; d[i]=f[d[i]]; }
    for (int i=1; i<=m; i++) x[i]=f[x[i]];

    sort(red.begin(), red.end());
    for (int i=0; i<red.size(); i++)
    {
        //cout<<i<<":"<<endl;
        if (red[i].yy==0)
        {
            //cout<<"usao u prvi"<<endl;
            //cout<<u[red[i].xx]<<" "<<d[red[i].xx]<<endl;
            upd(u[red[i].xx], +1);
            upd(d[red[i].xx]+1, -1);
        }
        else
        {
            //cout<<"usao u drugi"<<endl;
            //x[red[i].yy]=f[x[red[i].yy]];
            //cout<<x[red[i].yy]<<" "<<sum(x[red[i].yy])<<endl;
            ress[red[i].yy].pb(sum(x[red[i].yy]));
        }
    }

    for (int i=1; i<=m; i++) cout<<ress[i][1]-ress[i][0]<<endl;

}