#include <bits/stdc++.h>
using namespace std;
long long d[200010], u[200010];
vector<long long> v[21];
vector<long long> v2[200010];
int main(){
	long long n,m;
	cin >> n >> m;
	bool tc4 = true;
	bool tc2 = true;
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld", &d[i], &u[i]);
		if(u[i] <= 20){
			for(int j = d[i]; j <= u[i]; j++){
				v[j].push_back(i);
			}
		}
		if(u[i] == d[i])
			v2[d[i]].push_back(i);
		if(u[i] != d[i])
			tc2 = false;
		if(u[i] > 20)
			tc4 = false;
	}
	if(tc4){
		while(m--){
			long long l, r, x;
			scanf("%lld %lld %lld", &l, &r, &x);
			auto lower = lower_bound(v[x].begin(), v[x].end(), l);
			auto upper = upper_bound(v[x].begin(), v[x].end(), r);
			long long lowerres = lower - v[x].begin() + 1;
			long long upperres = upper - v[x].begin() + 1;
			printf("%lld\n", upperres - lowerres);
		}
		return 0;
	}
	if(tc2){
		while(m--){
			long long l, r, x;
			scanf("%lld %lld %lld", &l, &r, &x);
			auto lower = lower_bound(v2[x].begin(), v2[x].end(), l);
			auto upper = upper_bound(v2[x].begin(), v2[x].end(), r);
			long long lowerres = lower - v2[x].begin() + 1;
			long long upperres = upper - v2[x].begin() + 1;
			printf("%lld\n", upperres - lowerres);
		}
		return 0;
	}
	while(m--){
		long long l, r, x;
		scanf("%lld %lld %lld", &l, &r, &x);
		long long res = 0;
		for(int i = l; i <= r; i++){
			if(x >= d[i] && x <= u[i])
				res++;
		}
		printf("%lld\n", res);
	}
	return 0;
}