#include <bits/stdc++.h>
# define endl            '\n'
# define clr(x,a)        memset(x,a,sizeof(x))
# define vi              vector<int>
# define all(a)          a.begin(), a.end()
# define deb(x)          cout<<#x<<"=="<<x<<endl;
# define pb              push_back
# define sc              scanf
# define pr              printf
# define tc              int t; cin>>t; while(t--)
# define rev(s)          reverse(s.begin(),s.end())
# define linija          cout<<"___________\n";
# define sza(x)          (int)x.size()
using namespace std;
typedef long long ll;
const int mxN=200005, mxM=200005, mod=1e9+7, LOG=30;
template<typename T> T nzd(T a, T b){if(b==0) return a;else return nzd(b, a%b);}
template<typename T> T nzs(T a, T b){return(a*(b/nzd(a,b)));}
template<typename T> T stepenuj(T e, T n){T x=1,p=e;while(n){if(n&1)x=(x*p)%mod;p=(p*p)%mod;n>>=1;}return x;}
template<typename T> inline T na2(T x){return x*x;}
int n, m, ft[mxN];
struct Vaga{
   int d, g, id;
   bool operator <(const Vaga &P)const{
      return P.g<g;
   }
}vage[mxN];
priority_queue<Vaga> q;
struct Query{
   int l, r, x, id, res;
}qveri[mxN];
bool cmp_x(Query a, Query b){return a.x<b.x;}
bool cmp_d(Vaga a, Vaga b){return a.d<b.d;}
bool cmp_id(Query a, Query b){return a.id<b.id;}
/*
pre toga valjda moram da skaliram sve //glup sam ko tri kurca
------
1) ubacim sve kojima je d < trenutnog x
2) izbacim sve kojima je g < trenutnog x
3) ft(r)-ft(l-1) je resenje
*/

void add(int x,int y){
	for(int i=x;i<=n;i+=(i&-i)) ft[i]+=y;
}
int query(int x){
	int res=0;
	for(int i=x;i;i-=(i&-i)) {
		res+=ft[i];
	}
	return res;
}

int main(){
//   freopen("in.txt", "r", stdin);
   sc("%d%d", &n, &m);
   for(int i=1; i<=n; i++){
      sc("%d%d", &vage[i].d, &vage[i].g);
      vage[i].id=i;
   }
   for(int i=1; i<=m; i++){
      sc("%d%d%d", &qveri[i].l, &qveri[i].r, &qveri[i].x);
      qveri[i].id=i;
   }
//   cout<<"sve sam uneo\n";
//   skaliraj(); //trebalo bi testirai :((
   sort(qveri+1, qveri+1+m, cmp_x);
   sort(vage+1, vage+1+n, cmp_d);   //ovo je sortirano po d-u
//   cout<<"Vage\n";
//   for(int i=1; i<=n; i++) cout<<vage[i].id<<" "<<vage[i].d<<" "<<vage[i].g<<endl;
//   cout<<"qveri\n";
//   for(int i=1; i<=m; i++) cout<<qveri[i].id<<" "<<qveri[i].x<<endl;
   int tren=1;
   for(int i=1; i<=m; i++){
      while(qveri[i].x>=vage[tren].d && tren<=n){
         add(vage[tren].id, 1);
//         cout<<"Ubacujem "<<vage[tren].id<<endl;
         q.push(vage[tren]);
         tren++;
      }
      if(q.size()){
         while(q.top().g<qveri[i].x){
//            cout<<"Izbacujem "<<q.top().id<<endl;
            add(q.top().id, -1);
            q.pop();
            if(q.size()==0) break;
         }
      }
//      cout<<"Racunam za "<<i<<"tu\n\n";
      qveri[i].res=query(qveri[i].r)-query(qveri[i].l-1);
   }
//   cout<<"gotovo ovo\n";
   sort(qveri+1, qveri+1+m, cmp_id);
//   cout<<"Solutions:\n";
   for(int i=1; i<=m; i++) pr("%d\n", qveri[i].res);

	return 0;
}