#include<iostream>
using namespace std;
struct Vaga{
	int d;
	int u;
};
struct Pitanja{
	int l;
	int r;
	int x;
};
void unesi(struct Vaga a[], int n)
{
	int brd;
	int bru;
	for(int i = 0; i < n; i++)
	{
		cin>>brd>>bru;
		a[i].d = brd;
		a[i].u =bru;
 	}
}
void pitanja(struct Pitanja b[], int m)
{
	int brl;
	int brr;
	int brx;
	for(int j = 0; j<m; j++)
	{
		cin>>brl>>brr>>brx;
		b[j].l = brl;
		b[j].r = brr;
		b[j].x = brx;
	}
}
int provera(struct Vaga a[], struct Pitanja b[], int q) 
{
	int i = 0;
	int qpp = q;
	int qp = b[qpp].l - 1;
	int qppp = b[qpp].r - 1;
	for(qp; qp <= qppp; qp++)
	{
		if(b[qpp].x >= a[qp].d && b[qpp].x <= a[qp].u)
		{
			i++;
		}
	}
	return i;
}
int main()
{
	int n, m;
	cin>>n>>m;
	int qx = 0;
	struct Vaga a[n];
	struct Pitanja b[m];
	unesi(a, n);
	pitanja(b, m);
	for(qx = 0; qx<m; qx++)
	{
		cout<<provera(a, b, qx)<<endl;
	}
}