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