#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;



class Vaga {
public:
	int d;
	int n;
};
class Zad {
public:
	int r;
	int x;
	int l;
};
void Vage(){
	int n, m;
	cin >> n >> m;
	vector <Vaga> vag;
	for (int i = 0; i < n; i++)
	{
		Vaga e;
		cin >> e.n;
		cin >> e.d;
		vag.push_back(e);
	}
	vector <Zad> zad;
	for (int i = 0; i < m; i++)
	{
		Zad za;
		cin >> za.l;
		cin >> za.r;
		cin >> za.x;
		zad.push_back(za);
	}
	
	for (int i = 0; i < zad.size(); i++)
	{

		Zad z = zad[i];
	
		int cnt = 0;
		for (int i = z.l-1; i < z.r; i++)
		{
			//cout << z.l << " " << z.r << " " << z.x << " " << " , I:" << i << " " << vag[i].d << " " << vag[i].n << endl;
			if (z.x <= vag[i].d && z.x >= vag[i].n )
				cnt++;
		}
		
		cout << cnt <<endl;
	}
}