#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    int tg[n][2];
    int l, r, x;

    int res[m];

    for (int q = 0; q < m; q++)
        res[q] = 0;

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 2; j++)
            cin >> tg[i][j];
    }

    for (int k = 0; k < m; k++){
        cin >> l >> r >> x;

        while(l <= r){
            if (tg[l][1] <= x && x <= tg[l][2])
                res[k]++;
            l++;
        }
    }

    for (int k = 0; k < m; k++)
            cout << res[k] << endl;

    return 0;
}