#include <bits/stdc++.h>

using namespace std;

#define MAXN 200010

long long n,m;
long long d[MAXN];
long long u[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;

    for (long long i=1;i<=n;i++) cin>>d[i]>>u[i];

    long long br=0;

    for (long long i=1;i<=n;i++)
    {
        if (u[i]<=20) br++;
    }

    if (n<=1000 and m<=1000)
    {
        for (long long i=1;i<=m;i++)
        {
            long long l,r,x;
            cin>>l>>r>>x;

            long long sum=0;

            for (long long j=l;j<=r;j++)
            {
                if (d[j]<=x and u[j]>=x) sum++;
            }

            cout<<sum<<endl;
        }
    }

    else if (br==n)
    {
        vector<long long> adj[30];

        for (long long i=1;i<=n;i++)
        {
            for (long long j=d[i];j<=u[i];j++) adj[j].push_back(i);
        }

        for (long long i=1;i<=m;i++)
        {
            long long l,r,x;
            cin>>l>>r>>x;

            if (x>20) cout<<0<<endl;
            else cout<<(lower_bound(adj[x].begin(),adj[x].end(),r+1))-(lower_bound(adj[x].begin(),adj[x].end(),l))<<endl;
        }
    }
}