#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define ima_li_te(D,d)  find(all(D),d)
#define MAXN 200007
ll d[MAXN],u[MAXN],l[MAXN],r[MAXN],x[MAXN],psum[21][MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,m; cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>d[i]>>u[i];
    for(int i=1;i<=m;i++) cin>>l[i]>>r[i]>>x[i];
    if(n*m<=10000007)
    {
        for(int i=1;i<=m;i++)
        {
            ll rez=0;
            for(int j=l[i];j<=r[i];j++)
            {
                if(d[j]<=x[i] && x[i]<=u[j]) rez++;
            }
            cout<<rez<<endl;
        }
    }
    else
    {
        bool check=true;
        for(int i=1;i<=n;i++)
        {
            if(u[i]>20)
            {
                check=false;
                break;
            }
        }
        if(check)
        {
            for(int i=0;i<=20;i++) psum[i][0]=0;
            for(int i=1;i<=n;i++)
            {
                for(int j=0;j<=20;j++) psum[j][i]=psum[j][i-1];
                for(int j=d[i];j<=u[i];j++) psum[j][i]++;
            }
            for(int i=1;i<=m;i++)
            {
                if(x[i]>20) cout<<0<<endl;
                else cout<<psum[x[i]][r[i]]-psum[x[i]][l[i]-1]<<endl;
            }
        }
        else
        {
            bool check=true;
            for(int i=1;i<=n;i++)
            {
                if(d[i]!=u[i])
                {
                    check=false;
                    break;
                }
            }
            if(check)
            {
                map<ll,vector<ll>> mm;
                map<ll,ll> cnt;
                for(int i=1;i<=n;i++) mm[d[i]].pb(i);
                for(int i=1;i<=n;i++) cnt[d[i]]++;
                for(int i=1;i<=m;i++)
                {
                    if(cnt[x[i]]==0) cout<<0<<endl;
                    else
                    {
                        ll itr1=lower_bound(all(mm[x[i]]),l[i])-mm[x[i]].begin();
                        ll itr2=upper_bound(all(mm[x[i]]),r[i])-mm[x[i]].begin();
                        if(itr1==cnt[d[i]] || itr2==0) cout<<0<<endl;
                        else cout<<itr2-itr1<<endl;
                    }
                }
            }
        }
    }
    return 0;
}