#include <bits/stdc++.h>

using namespace std;

int n, m, br;
int d[1000];
int u[1000];
int l[1000];
int r[1000];
int x[1000];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for (int i=1; i<=n; i++){
        cin >> d[i] >> u[i];
    }
    for (int i=0; i<m; i++){
        cin >> l[i] >> r[i] >> x[i];
    }
    for (int i=0; i<m; i++){
        br=0;
        for (int j=l[i]; j<=r[i]; j++){
            if (x[i]>=d[j] && x[i]<=u[j]) br++;
        }
        cout << br << "\n";
    }
    return 0;
}