#include <stdio.h>
#include <stdlib.h>

int main(){
    
    int n, m, *donja, *gornja, *resenja, k, i, j, provera, brojac = 0;
    scanf("%d %d", &n, &m);
    donja = (int*)malloc(n * sizeof(int));
    gornja = (int*)malloc(n * sizeof(int));
    resenja = (int*)malloc(m * sizeof(int));
    
    for (i=0;i<n;i++){
        scanf("%d %d", &donja[i], &gornja[i]);
    }
    
    for(k=0;k<m;k++){
        scanf("%d %d %d", &i, &j, &provera);
        for(i;i<=j;i++){
            if (provera >= donja[i-1] && provera <= gornja[i-1]){
                brojac++;
            }
        }
        printf("%d\n", brojac);
        brojac=0;
    }
    
    return 0;
}