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

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int *d=(int*)malloc(n*sizeof(int));
    int *u=(int*)malloc(n*sizeof(int));
    int maxu=0;
    for (int i=0;i<n;i++)
    {
        scanf("%d%d",&d[i],&u[i]);
        if (u[i]>maxu) maxu=u[i];
    }

    if (maxu<=100)
    {
        int** brojac=(int**)malloc((n+10)*sizeof(int*));
        for (int i=1;i<=n;i++) brojac[i]=(int*)calloc(100,sizeof(int));
        for (int i=1;i<=n;i++)
        {
            for (int j=d[i-1];j<=u[i-1];j++) brojac[i][j]=brojac[i-1][j]+1;
        }
        for (int i=0;i<m;i++)
        {
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            if (x>100)
            {
                printf("0\n");
                continue;
            }
            l;
            r;
            printf("%d\n",brojac[r][x]-brojac[l-1][x]);
        }
        return 0;
    }

    for (int i=0;i<m;i++)
    {
        int l,r,x;
        scanf("%d%d%d",&l,&r,&x);
        l--;r--;
        int br=0;
        for (int j=l;j<=r;j++) if (u[j]>=x && d[j]<=x) br++;
        printf("%d\n",br);
    }
}