#include <bits/stdc++.h>
#define MAXN 200010

using namespace std;

typedef long long ll;

int n, m, x, y, z;
vector<tuple<int, int, int, int, int>> v;

int fs[MAXN];
int rez[MAXN];

int ZbirPrefiksa(int k)
{
    int zbir = 0;
    while (k > 0)
    {
        zbir += fs[k];
        k -= k & -k;
    }
    return zbir;
}

void Dodaj(int k, int x)
{
    while (k <= n)
    {
        fs[k] += x;
        k += k & -k;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> x >> y;
        v.push_back(make_tuple(x, 1, i, 0, 0));
        v.push_back(make_tuple(y, 3, i, 0, 0));
    }
    for(int i = 1; i <= m; i++)
    {
        cin >> x >> y >> z;
        v.push_back(make_tuple(z, 2, x, y, i));
    }
    sort(v.begin(), v.end());
    for(auto a : v)
    {
        if(get<1>(a) == 1)
        {
            Dodaj(get<2>(a), 1);
        }
        else if(get<1>(a) == 2)
        {
            rez[get<4>(a)] = ZbirPrefiksa(get<3>(a)) - ZbirPrefiksa(get<2>(a) - 1);
        }
        else
        {
            Dodaj(get<2>(a), -1);
        }
    }
    for(int i = 1; i <= m; i++)
    {
        cout << rez[i] << "\n";
    }
    return 0;
}