#include <iostream>
using namespace std;
main()
{
    int i, j, N, M;
    cin>>N;
    cin>>M;
    int d[N], u[N], l[M], r[M], x[M], br[M];
    for(i = 0; i < N; i++)
    {
        cin>>d[i];
        cin>>u[i];
    }
    for(i = 0; i < M; i++)
    {
        cin>>l[i];
        cin>>r[i];
        cin>>x[i];
    }	
    for(i = 0; i < M; i++)
    {
    	br[i] = 0;
    	for(j=l[i]-1;j<=r[i]-1;j++)
    	{
    		if(d[j]<=x[i] && x[i]<=u[j])
    			br[i]++;
    	}
	}
	for(i = 0; i < M; i++)
		cout<<br[i]<<endl;
}