#include <bits/stdc++.h>


using namespace std;



const int Nmax=200005;
 //vector<vector<int>> interval;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n,m;
   cin>> n>>m;
   vector <int> d(n), u(n);
   int jednaki=0;
   bool sub2=false;
//   interval.resize(20);

 /*  for (int i=0;i<20;i++)
     interval[i].resize(n);*/

   for(int i=0; i<n; i++)
     {
         cin >>d[i]>>u[i];

         /*for (int k=d[i]; k<=u[i];k++){
         interval[d[i]].push_back(k);
         interval[u[i]].push_back(k);
         }*/
         jednaki+=(d[i]==u[i]);
     }
     if (jednaki==n) sub2=!sub2;
     int mini1=*min_element(d.begin(),d.end());
     //int maxi1=*max_element(d.begin(),d.end());
     //int minii2=*min_element(u.begin(),u.end());
     int maxi2=*max_element(u.begin(),u.end());
    /* for (auto x: d)
        cout << x << " ";
     cout <<endl;
      for (auto x: u)
        cout << x << " ";
     cout <<endl;*/


    /* vector<unsigned long long> pref(n,0);
     if (sub2)
     {
         pref[0]=d[0];
         for(int i=1; i<n; i++)
            pref[i]=pref[i-1]+d[i];
     }*/


     if (sub2)
     {
         for(int i=0; i<m; i++)
        {int l,r,x;
     cin >> l >> r >> x;
     l--; r--;
     int br=0;
    // if (sub2)

        for(int j=l; j<=r; j++)if(d[j]==x)br++;
        cout << br << endl;
     }
     }



     else //if(n<=1000 and m<=1000)
        {

        for(int i=0; i<m; i++)
        {int l,r,x;
     cin >> l >> r >> x;
     l--; r--;
     int br=0;
    // if (sub2)
    if(x<mini1 or x>maxi2)br=0;

        else for(int j=l; j<=r; j++)if(d[j]<=x and u[j]>=x)br++;
        cout << br << endl;
     }
     }



     /*else
     {
          for(int i=0; i<m; i++)
        {int l,r,x;
     cin >> l >> r >> x;
     l--; r--;
        cout << interval[x].size() << endl;
     }*/



     //}

      return 0;
}