#include <iostream>

using namespace std;

int main()
{
    int N, M;
    
    cin >> N;
    cin >> M;
    
    int donjaGranica[N], gornjaGranica[N];
    
    for (int i = 0; i < N; i++) {
        cin >> donjaGranica[i];
        cin >> gornjaGranica[i];
    }
    
    int mozeDaIzracuna[M];
    
    for (int i = 0; i < M; i++) {
        int startniIndex, krajnjiIndex, trazenaTezina;
        cin >> startniIndex;
        cin >> krajnjiIndex;
        cin >> trazenaTezina;
        
        mozeDaIzracuna[i] = 0;
        for (int j = startniIndex; j<=krajnjiIndex; j++) {
            if (donjaGranica[j-1]<=trazenaTezina && gornjaGranica[j-1]>=trazenaTezina) {
                mozeDaIzracuna[i]++;
            }
        }
    }
    
    for (int i = 0; i < M; i++) {
        cout<<mozeDaIzracuna[i]<<endl;
    }
    
    return 0;
}