#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int N, M;   // N - Broj vagi; M - Broj pitanja

    cin >> N >> M;

    int vGornje[N], vDonje[N];

    int d, u;
    for (int i = 0; i < N; i++){
        cin >> d >> u;
        vGornje[i] = u;
        vDonje[i] = d;
    }

    int t, minD, maxU, brojac;
    for (int i = 0; i < M; i++){
        brojac = 0;
        cin >> d >> u >> t;

        d--;
        u--;

        for (int i = d; i <= u; i++){
            if (t >= vDonje[i] && t <= vGornje[i]){
                brojac++;
            }
        }

        cout << brojac << "\n";
    }
}