#include <iostream>

using namespace std;

int main()
{
    int n, m, l, r, x;
    cin>>n>>m;
    int donje[n], gornje[n], brojac[m];
    for(int i=0;i<n;i++)
    {
        cin>>donje[i]>>gornje[i];
    }
    for(int p=0;p<m;p++)
    {
        brojac[p]=0;
        cin>>l>>r>>x;
        for(int i=l-1;i<r;i++)
        {
            if(x>=donje[i] && x<=gornje[i])
                brojac[p]++;
        }
    }
    for(int p=0;p<m;p++)
        cout<<brojac[p]<<endl;
    return 0;
}