#include <iostream>
#include <list>

using namespace std;

int main()
{
    int n,m,li,ri,xi;
    cin>>n>>m;
    int br=0;
    int l1[n*2];
    int l[m];
    for (int i = 0; i < n; i++){
        cin >> l1[2*i]>>l1[2*i+1];
    }
    for (int q = 0; q < m; q++){
        cin >> li>>ri>>xi;
        for (li;li<=ri;li++){
            if (xi<=l1[(li-1)*2+1] && xi>=l1[(li-1)*2]) {
                br+=1;
            }
            
            
        }
        
        l[q]=br;
        br=0;
    }
    for (int u=0;u<m;u++){
        cout<<l[u]<<endl;
    }
    

    return 0;
}