#include <bits/stdc++.h>

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;

    cin >> n >> m;

    vector<int> ub(n), lb(n);

    for(int i = 0; i < n; ++i) cin >> lb[i] >> ub[i];

    auto build = [&](int l, int r, int ind, vector<int>& a, vector<vector<int>>& wMst, auto build) -> void {
        if(l == r) { wMst[ind].push_back(a[l]); return; }

        int mid = (l + r) >> 1, tmpInd = (ind << 1) + 1;
        build(l, mid, tmpInd, a, wMst, build), build(mid+1, r, tmpInd+1, a, wMst, build);
        wMst[ind].resize(r - l + 1);

        merge(wMst[tmpInd].begin(), wMst[tmpInd].end(), wMst[tmpInd+1].begin(), wMst[tmpInd+1].end(), wMst[ind].begin());
        return;
    };

    auto queryGEImpl = [&](int ind, int ql, int qr, int tl, int tr, int x, vector<vector<int>>& wMst, auto queryGEImpl) -> int {
        if(tr < ql || qr < tl) return 0;
        if(ql <= tl && tr <= qr) return wMst[ind].end() - lower_bound(wMst[ind].begin(), wMst[ind].end(), x);

        int mid = (tl + tr) >> 1;
        return queryGEImpl((ind << 1) + 1, ql, qr, tl, mid, x, wMst, queryGEImpl) + queryGEImpl((ind << 1) + 2, ql, qr, mid+1, tr, x, wMst, queryGEImpl);
    };

    auto queryGImpl = [&](int ind, int ql, int qr, int tl, int tr, int x, vector<vector<int>>& wMst, auto queryGImpl) -> int {
        if(tr < ql || qr < tl) return 0;
        if(ql <= tl && tr <= qr) return wMst[ind].end() - upper_bound(wMst[ind].begin(), wMst[ind].end(), x);

        int mid = (tl + tr) >> 1;
        return queryGImpl((ind << 1) + 1, ql, qr, tl, mid, x, wMst, queryGImpl) + queryGImpl((ind << 1) + 2, ql, qr, mid+1, tr, x, wMst, queryGImpl);
    };

    auto queryG = [&](int l, int r, int x, vector<vector<int>>& wMst) -> int {
        return queryGImpl(0, l, r, 0, n-1, x, wMst, queryGImpl);
    };

    auto queryGE = [&](int l, int r, int x, vector<vector<int>>& wMst) -> int {
        return queryGEImpl(0, l, r, 0, n-1, x, wMst, queryGEImpl);
    };

    vector<vector<int>> ubMst(n << 2), lbMst(n << 2);
    build(0, n-1, 0, lb, lbMst, build), build(0, n-1, 0, ub, ubMst, build);

    while(m--){
        int l, r, x;

        cin >> l >> r >> x;
        --l, --r;

        cout << queryGE(l, r, x, ubMst) - queryG(l, r, x, lbMst) << '\n';
    }
    return 0;
}