#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector <pair<int, int>> a;
    int p, q;
    for (int i = 0; i < n; i++)
    {
        cin >> p >> q;
        a.push_back(make_pair(p, q));
    }
    int li, ri, xi, brojac;
    for (int i = 0; i < q; i++)
    {
        brojac = 0;
        cin >> li >> ri >> xi;
        li--;
        ri--;
        for (li; li <= ri; li++)
        {
            if(xi >= a[li].first && xi <= a[li].second) brojac++;
        }
        cout << brojac << endl;
    }
}