#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    int n = 0;
    int m = 0;
    cin >> n >> m;
    int d[n];
    int u[n];
    int l;
    int r;
    int x;

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

    int brojac = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> l >> r >> x;
        brojac = 0;
        for (int j = l; j <= r; j++)
        {
            if (x >= d[j - 1] && x <= u[j - 1])
            {
                brojac++;
            }
        }
        cout << brojac << endl;
    }



    return 0;
}