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

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    
	vector<int> vage, pitanja;
	int brojvaga, brojpitanja, brojac=0;
	
	cin >> brojvaga >> brojpitanja;
	for (int i = 0; i<brojvaga*2; i++) {	//cin
		int a; cin >> a;
		vage.push_back(a);
	}
	for (int i = 0; i<brojpitanja*3; i++) { //cin
		int a; cin >> a;
		pitanja.push_back(a);
	}
	for (int i = 1; i<=brojpitanja*3; i++){
		int a=i*3-1, b=(i-1)*3, c=pitanja[b] *2 - 1, d = pitanja[a] *2 - 2;
		int x = pitanja[a], y = vage[c], z = vage[d];	
		if (x<=y && x>=z){
			brojac += 1;
		}
		cout << brojac << '\n';
	}
	
	cout << brojac << '\n';

return 0;
}