#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, br;
    cin >> n >> m;
    vector<int> d(n);
    vector<int> u(n);
    bool jednako = true;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> u[i];
        if(jednako and d[i] != u[i]){
            jednako = false;
        }
    }
    vector<int> l(m);
    vector<int> r(m);
    vector<int> x(m);
    for(int i = 0; i < m; i++) {
        cin >> l[i] >> r[i] >> x[i];
    }
    if(jednako){
        for(int i = 0; i < m; i++){
            cout << count(d.begin()+l[i]-1, d.begin()+r[i], x[i]) << endl;
        }
    }else{
        for(int i = 0; i < m; i++){
            br = 0;
            for(int j = l[i]-1 ; j < r[i]; j++) {
                if( x[i] >= d[j] && x[i] <= u[j]){
                    br++;
                }
            }
            cout << br << endl;

        }
    }
}