#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip> 
#include <map>
#include <string>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <iterator>
#include <queue>
#include <set>


#define f(n) for (long long i = 0; i < n; i++)
#define f0(n) for (int j = 0; j < n; j++)
#define co(n) cout << n << "\n";

using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
    return (a.second < b.second);
}

void buildd(vector<int> a, vector<int> b, int v, int l, int r, vector<vector<pair<int,int>>> &td)
{
    if (l == r) 
    {
        td[v] = vector<pair<int,int>>(1, pair<int,int>(a[l],b[l]));
    }
    else 
    {
        int m = (l + r) / 2;
        buildd(a, b, v * 2, l, m, td);
        buildd(a, b, v * 2 + 1, m + 1, r, td);
        merge(td[v * 2].begin(), td[v * 2].end(), td[v * 2 + 1].begin(), td[v * 2 + 1].end(), back_inserter(td[v]));
    }
}

vector<pair<int,int>> qmin(int v, int tl, int tr, int l, int r, vector<vector<pair<int,int>>> &t)
{
    vector<pair<int, int>> pv;
    if (l > r) return pv;
    if (l == tl && r == tr) pv = t[v];
    else
    {
        int tm = (tl + tr) / 2;
        vector<pair<int, int>> p1 = qmin(v * 2, tl, tm, l, min(r, tm), t), p2 = qmin(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, t);
        merge(p1.begin(), p1.end(), p2.begin(), p2.end(), back_inserter(pv));
    }
    return pv;
}

int qq(vector<pair<int, int>> &pv, int x)
{
    int i = lower_bound(pv.begin(), pv.end(), pair<int,int>(x,0), sortbysec) - pv.begin();
    pv.erase(pv.begin(), pv.begin() + i);
    int r = 0;
    for (pair<int, int> a : pv) if (a.first <= x && x <= a.second) r++;
    return r;
}

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

    int n, m;
    cin >> n >> m;

    vector<vector<pair<int,int>>> td(4 * n);

    vector<int> vd(n);
    vector<int> vu(n);

    map<int, pair<int, int>> v;
    f(n)
    {
        int a, b;
        cin >> a >> b;
        v[i] = pair<int, int>(a, b);
        vd[i] = a;
        vu[i] = b;
    }

    vector<tuple<int, int, int>> u(m);
    f(m)
    {
        int a0, a1, a2;
        cin >> a0 >> a1 >> a2;
        u[i] = make_tuple(a0 - 1, a1 - 1, a2);
    }

    buildd(vd, vu, 1, 0, n - 1, td);

    f(m)
    {
        vector<pair<int, int>> pg = qmin(1, 0, n - 1, get<0>(u[i]), get<1>(u[i]), td);
        cout << qq(pg, get<2>(u[i])) << "\n";
    }
}