#include <bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int n, m; cin >> n >> m;
	vector< pair <int,int> > vektor;
	for(int i = 1; i <= n; i++){
		int a, b;
		cin >> a >> b;
		vektor.push_back(make_pair(a,b));
	}
	for(int i = 0; i < m; i++){
		int l,r,x, brojac = 0;
		cin >> l >> r >> x;
		for(int j = l-1; j < r; j++){
			if(vektor[j].first <= x && x <=vektor[j].second){
				brojac++;
			}
		}
		cout<<brojac<<endl;
	}
}