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

int pow_i(int, int);

int main()
{
    int N, M;

    scanf("%d%d", &N, &M);

    if (N < 1 || N > 2 * pow_i(10, 5) || M < 1 || M > 2 * pow_i(10, 5)) 
        return 0;

    int *d = malloc(N * sizeof(int));
    int *u = malloc(N * sizeof(int));

    for (int i = 0; i < N; i++) {
        scanf("%d%d", &d[i], &u[i]);

        if (u[i] < d[i] || d[i] < 0 || u[i] > pow_i(10, 9))
            return 0;
    }

    int *l = malloc(M * sizeof(int));
    int *r = malloc(M * sizeof(int));
    int *x = malloc(M * sizeof(int));

    for (int i = 0; i < M; i++) {
        scanf("%d%d%d", &l[i], &r[i], &x[i]);

        if (r[i] < l[i] || l[i] < 1 || r[i] > N)
            return 0;
    }
    
    for (int i = 0, br_vaga; i < M; i++)
    {
        if (i != 0)
            putchar('\n');

        br_vaga = 0;

        for (int j = l[i] - 1; j <= r[i] - 1; j++)
            if (x[i] >= d[j] && x[i] <= u[j])
                br_vaga++;

        printf("%d", br_vaga);    
    }
}

int pow_i(int base, int exp)
{
    if (exp == 0)
        return 1;

    int tmp = base;

    while (--exp)
        base *= tmp;

    return base;
}