#include <iostream>
using namespace std;

int main()
{
	int n, m, d[10000], u[10000], l[10000], x[10000], r[10000];
	int brojac;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i] >> u[i];
		if (d[i] > u[i])
		{
			cout << "greska";
			exit;
		}
	}
	for (int j = 0; j < m; j++)
	{
		cin >> l[j] >> r[j] >> x[j];
		if (l[j] > r[j])
		{
			cout << "greska";
			exit;
		}
	}
	for (int k = 0; k < m; k++)
	{
		brojac = 0;
		for (int p = l[k]; p <= r[k]; p++)
		{
			if (d[p] <= x[k] && x[k] <= u[p])
			{
				brojac++;
			}
		}
		cout << brojac << endl;
	}
}