#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	pair<int, int> o[n];
	bool z = true;
	map<int, vector<int>> t; 
	for(int i = 0; i < n; i++) {
		cin >> o[i].first >> o[i].second;
		if(o[i].first != o[i].second) z = false;
		t[o[i].first].push_back(i + 1);

	}
	if(n<=1000 && m <=1000) {
	
	for(int i = 0; i < m; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		int re = 0;
		for(int j = l - 1; j < r ; j++) {
			if(x >= o[j].first && x <= o[j].second) re++;
		}
		cout << re << "\n";
	}
} 
	else if(z) {

	for(int i = 0; i < m; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		int f = lower_bound(t[x].begin(), t[x].end(), l) - t[x].begin();
		int ff = upper_bound(t[x].begin(), t[x].end(), r) - t[x].begin();
		ff--;
		if(ff < f) cout << 0 << "\n";
		else cout << ff - f + 1 << "\n";
	}
}
	else{
		cout << "The cake is a lie.";
	}
	return 0;
}