#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

class BIT{

    int n;
    vector<ll> tree;

    ll query(int pos) const {
        if (pos > n) pos = n;
        ll sum = 0;
        for (; pos; pos -= (pos & (-pos)))
            sum += tree[pos];
        return sum;
    }
public:
    BIT(int n = 0){ Assign(n); }
    void Assign(int s){
        n = s;
        tree.assign(s+1, 0);
    }
    ll query(int l, int r) const {
        l++; r++;
        if (l > r) return 0;
        return query(r) - query(l-1);
    }
    void update(ll x, int pos){
        pos++;
        if (pos < 1) return;
        for (; pos <= n; pos += (pos & (-pos)))
            tree[pos] += x;
    }
};

const ll LINF = 4e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, ans[mxN];
array<ll, 3> a[mxN];
array<ll, 4> q[mxN];
BIT fen;

void Solve(){

    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> a[i][1] >> a[i][0];
        a[i][2] = i;
    }
    sort(a, a+n);
    for (int i = 0; i < m; i++){
        cin >> q[i][1] >> q[i][2] >> q[i][0];
        q[i][1]--; q[i][2]--;
        q[i][3] = i;
    }
    sort(q, q+m);
    fen.Assign(n);
    for (int i = 0, j = 0; i < m; i++){
        for (; j < n && a[j][0] < q[i][0]; j++)
            fen.update(1, a[j][2]);
        ans[q[i][3]] += fen.query(q[i][1], q[i][2]);
    }
    for (int i = 0; i < n; i++)
        swap(a[i][0], a[i][1]);
    sort(a, a+n);
    reverse(a, a+n);
    reverse(q, q+m);
    fen.Assign(n);
    for (int i = 0, j = 0; i < m; i++){
        for (; j < n && a[j][0] > q[i][0]; j++)
            fen.update(1, a[j][2]);
        ans[q[i][3]] += fen.query(q[i][1], q[i][2]);
    }
    for (int i = 0; i < m; i++)
        ans[q[i][3]] = q[i][2] - q[i][1] + 1 - ans[q[i][3]];
    for (int i = 0; i < m; i++)
        cout << ans[i] << en;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;
    cerr << "Started!" << endl;

    int t = 1;
    //cin >> t;
    while (t--)
        Solve();

    return 0;
}