#include <iostream>
using namespace std;

class vaga
{
private:
	int m_min, m_max;
public:
	vaga() {}
	vaga(int min, int max) : m_min(min), m_max(max) {}

	bool moze_da_izmeri(int tezina)
	{
		if (tezina < m_min || tezina > m_max) return false;
		return true;
	}
};

int main()
{
	int n, m;
	cin >> n >> m;

	vaga* vage = new vaga[n];

	int i1, i2, t;
	for (int i = 0; i < n; i++)
	{
		cin >> i1 >> i2;
		vage[i] = vaga(i1, i2);
	}

	int* res = new int[m];

	for (int i = 0; i < m; i++)
	{
		cin >> i1 >> i2 >> t;
		int kol = 0;
		for (int j = i1 - 1; j < i2; j++) if (vage[j].moze_da_izmeri(t)) kol++;
		res[i] = kol;
	}

	for (int i = 0; i < m; i++) cout << res[i] << endl;
	delete[] vage;
	delete[] res;
}