#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    pair<int,int> p[n];
    for(int i = 0;i<n;i++){
        cin >> p[i].first >> p[i].second;
    }
    int br[m];
    for(int i = 0;i<m;i++){
        br[i]=0;
        int l,r,x;
        cin >> l >> r >> x;
        for(int j = l-1;j<=r-1;j++){
            if(p[j].first <= x && x<=p[j].second){
                br[i]++;
            }
        }
        cout << br[i] << endl;
    }
    return 0;
}