#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, m;
    cin >> n >> m;
    long long d[20000], u[20000];
    long long l[20000], r[20000], x[20000];
    for (long long i = 0; i < n; i++) cin >> d[i] >> u[i];
    for (long long i = 0; i < m; i++) cin >> l[i] >> r[i] >> x[i];
    long long br = 0;
    for (long long i = 0; i < m; i++)
    {
        for (long long j = l[i] - 1; j < r[i]; j++)
            if (d[j] <= x[i] && x[i] <= u[j]) br++;
        cout << br << endl;
        br = 0;
    }
    return 0;
}