#include <stdio.h>
#include <stdlib.h>
int main()
{
    struct granice
    {
        int dg;
        int gg;
    };

    struct pitanja
    {
        int l;
        int r;
        int x;
    };

    struct granice g[100];
    struct pitanja p[100];
    int n,m,i,j,broj=0,r1,l1,x1,kr,po,y;
    scanf("%d%d", &n, &m);

    for(i=0;i<n;i++)
    {
        scanf("%d%d", &g[i].dg, &g[i].gg);
    }

    for(j=0;j<m;j++)
    {
        scanf("%d%d%d", &p[j].l, &p[j].r, &p[j].x);
    }


    for(y=0;y<m;y++)
    {
        l1=p[y].l;
        r1=p[y].r;
        x1=p[y].x;
        if(l1>r1){
            kr=l1-1;
            po=r1-1;
        }
        else if(r1>l1){
            kr=r1-1;
            po=l1-1;
        }
        else if(l1==r1)
        {
            kr=l1-1;
            po=kr-1;
        }

        for(i=po;i<=kr;i++)
        {
            if(x1>=g[i].dg && x1<=g[i].gg)
            {
                broj++;
            }
        }
        printf("\n%d", broj);
        broj=0;
    }

    return 0;
}