#include <bits/stdc++.h>
using namespace std;

int main(){

    int n;
    int m;
    cin>>n>>m;
    int arr1[n];
    int arr2[n];
    int gradient1[m];
    int gradient2[m];
    int mass_lim[m];


    for(int i = 0; i<=n-1; i++){

        cin>>arr1[i];
        cin>>arr2[i];
    }

    for(int i = 0; i<=m-1; i++){

        cin>>gradient1[i];
        cin>>gradient2[i];
        cin>>mass_lim[i];
    }

    for(int i = 0; i<=m-1; i++){

        int res = 0;

        for(int k = gradient1[i]-1; k<=gradient2[i]-1; k++){

            if(mass_lim[i]>= arr1[k] && mass_lim[i]<=arr2[k]){

                res+=1;
            }
        }

        cout<<res<<endl;

    }

}