#include <iostream>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n,m,l,r,x,o,g,p;
    cin>>n>>m;
    map <int, set<int>> c;
    set<int> h;
    int a[n];
    int b[n];
    bool d = true;
    for (int i = 0; i<n; i++)
    {
        cin>>g>>p;
        if (g == p)
        {
            if (c.find(g) == c.end())
            {
                h.clear();
                h.insert(i);
                c.insert({g, h});
            }
            else
            {
                h = c[g];
                h.insert(i);
                c[g] = h;
            }
        }
        else
            d = false;
        a[i]=g;
        b[i]=p;
    }
    if (d)
    {
        for (int i = 0; i<m; i++)
        {
            o = 0;
            cin>>l>>r>>x;
            for (int j = l - 1; j<r; j++)
            {
                if (c.find(j) != c.end())
                {
                    o+=c[j].size();
                }
            }
            cout<<o<<endl;
        }
    }
    else
    {
        for (int i = 0; i<m; i++)
        {
            o=0;
            cin>>l>>r>>x;
            for (int j = l - 1; j<r; j++)
            {
                if (a[j] <= x && b[j] >= x)
                    o++;
            }
            cout<<o<<endl;
        }
    }


    return 0;
}