#include <bits/stdc++.h>
#define ll long long
#define en '\n'
#define sp ' '

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> d (N);
    vector<int> u (N);
    bool jednako = true;
    bool manje = true;
    for (int i = 0; i < N; i++)
    {
        cin >> d[i] >> u[i];
        if (d[i] != u[i])
            jednako = false;
        if (u[i] > 20)
            manje = false;
    }
    vector<int> l (M);
    vector<int> r (M);
    vector<int> x (M);
    for (int i = 0; i < M; i++)
        cin >> l[i] >> r[i] >> x[i];
    for (int i = 0; i < M; i++)
        l[i]--, r[i]--;
    if (N <= 1000 && M <= 1000)
    {
        for (int i = 0; i < M; i++)
        {
            int ans = 0;
            for (int j = l[i]; j <= r[i]; j++)
            {
                if (x[i] >= d[j] && x[i] <= u[j])
                    ans++;
            }
            cout << ans << en;
        }
    }
}