#include <iostream>

using namespace std;

int main()
{
    int v, p;
    cin >> v>>p;
    int* min = new int[v];
    int* max = new int[v];
    for (size_t i = 0; i < v; i++)
    {
        cin >> min[i] >> max[i];
    }
    for (size_t i = 0; i < p; i++)
    {
        int from, to, tezina;
        cin >> from >> to>> tezina;
        int n = 0;
        for (size_t i = from-1; i <= to-1; i++)
        {
            if (min[i] <= tezina && tezina <= max[i])
                n++;
        }
        cout << n << "\n";
    }
}