#include <iostream>

using namespace std;

typedef struct {
    int donja, gornja;
} Tezina;

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

    Tezina t[n];

    int l, r, x;

    int res[m];

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

    for (int i = 1; i <= n; i++)
           cin >> t[i].donja >> t[i].gornja;

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

        while(l <= r){
            if (t[l].donja <= x && x <= t[l].gornja)
                res[k]++;
            l++;
        }
    }

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

    return 0;
}