#include <bits/stdc++.h>

#define MAXN 200010

using namespace std;

int u[MAXN];
int v[MAXN];

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

    bool tc1 = n <= 1000 && m <= 1000;
    bool tc2 = !tc1;
    bool tc3 = !tc1;
    bool tc4 = !tc1;
    bool tc5 = !tc1;

    for(int i = 1; i <= n; i++) {
        cin >> u[i] >> v[i];
        if(u[i] != v[i])
            tc2 = false;
        if(v[i] > 20)
            tc4 = false;
    }

    if(tc2) {
        map<int,vector<int>> mymap;
        for(int i = 1; i <= n; i++)
            mymap[u[i]].push_back(i);
        for(int j = 0; j < m; j++) {
            int a,b,x;
            cin >> a >> b >> x;
            if(mymap.find(x) == mymap.end())
                cout << 0 << endl;
            else {
                vector<int> wx = mymap[x];
                int p = lower_bound(wx.begin(), wx.end(), a) - wx.begin();
                int r = upper_bound(wx.begin(), wx.end(), b) - wx.begin();
                cout << (r - p) << endl;
            }
        }
        return 0;
    }

//    if(tc3) {
//        // return 0;
//    }

    if(tc4) {
        vector<int> w[21];
        for(int i = 1; i <= n; i++)
            for(int j = u[i]; j <= v[i]; j++)
                w[j].push_back(i);
        for(int j = 0; j < m; j++) {
            int a,b,x;
            cin >> a >> b >> x;
            if(x > 20)
                cout << 0 << endl;
            else {
                int p = lower_bound(w[x].begin(), w[x].end(), a) - w[x].begin();
                int r = upper_bound(w[x].begin(), w[x].end(), b) - w[x].begin();
                cout << (r - p) << endl;
            }
        }
        return 0;
    }

//    if(tc5) {
//        // return 0;
//    }

    // jednostavan algoritam
    for(int j = 0; j < m; j++) {
        int a,b,x;
        cin >> a >> b >> x;
        int r = 0;
        for(int k = a; k <= b; k++) {
            if(u[k] <= x && v[k] >= x)
               r++;
        }
        cout << r << endl;
    }

    return 0;
}