#include <bits/stdc++.h>

#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n, m, l, r, x;
    cin >> n >> m;
    vector<ll> d(n);
    vector<ll> u(n);

    for (ll i = 0; i < n; i++) {
        cin >> d[i] >> u[i];
    }

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