#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b)
{
    if(a.first.first!=b.first.first)
        return a.first.first<b.first.first;
    return a.first.second<b.first.second;
}

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

    int n, m;cin>>n>>m;
    bool drugi = true;
    pair<pair<int, int>, int> vage[n];
    for(int i = 0; i<n; i++)
    {
        cin>>vage[i].first.first>>vage[i].first.second;
        vage[i].second = i;
    }


    if(n<=1000 && m<=1000){
        for(int i = 0; i<m; i++)
        {
            int l, r, x;
            cin>>l>>r>>x;
            int ans = 0;
            for(int i = l-1; i<r; i++)
            {
                if(vage[i].first.first<=x && vage[i].first.second>=x)ans++;
            }
            cout<<ans<<"\n";
        }
    }else
    {
        sort(vage, vage+n, cmp);
        for(auto g:vage)
            cout<<g.first.first<<" "<<g.first.second<<" "<<g.second<<endl;
        for(int i = 0; i<m; i++)
        {
            int l, r, x;
            cin>>l>>r>>x;

            int low = 0, high=n-1;
            while(low<=high)
            {
                int s = low + (high-low)/2;
                if(vage[s].first.first<=x && vage[s].first.second>=x)
                {
                    low = s;high=s;
                    break;
                }else if(vage[s].first.second<x)
                    low = s+1;
                else
                    high = s - 1;
            }
            if(low==high && vage[low].second>=l-1 && vage[low].second<=r-1)
                cout<<"1\n";
            else
                cout<<"0\n";

        }
    }
    return 0;
}