#include<bits/stdc++.h>
using namespace std;

int n, m, odg[200010];
pair<int, int> a[200010], b[200010];
struct sta {
    int l, r, w, k;
} q[200010];
bool nacin(const sta& A, const sta& B) {
    return A.w<B.w;
}
int st1[800010], st2[800010];
void upd1(int node, int tl, int tr, int poz) {
    if(tl==tr) {st1[node]=1; return;}
    int mid=(tl+tr)/2;
    if(poz<=mid) upd1(2*node, tl, mid, poz);
    else upd1(2*node+1, mid+1, tr, poz);
    st1[node]=st1[2*node]+st1[2*node+1];
}
void upd2(int node, int tl, int tr, int poz) {
    if(tl==tr) {st2[node]=1; return;}
    int mid=(tl+tr)/2;
    if(poz<=mid) upd2(2*node, tl, mid, poz);
    else upd2(2*node+1, mid+1, tr, poz);
    st2[node]=st2[2*node]+st2[2*node+1];
}
int query1(int node, int tl, int tr, int gl, int gr) {
    if(tl>=gl && tr<=gr) return st1[node];
    int mid=(tl+tr)/2;
    int suma=0;
    if(mid>=gl) suma+=query1(2*node, tl, mid, gl, gr);
    if(mid+1<=gr) suma+=query1(2*node+1, mid+1, tr, gl, gr);
    return suma;
}
int query2(int node, int tl, int tr, int gl, int gr) {
    if(tl>=gl && tr<=gr) return st2[node];
    int mid=(tl+tr)/2;
    int suma=0;
    if(mid>=gl) suma+=query2(2*node, tl, mid, gl, gr);
    if(mid+1<=gr) suma+=query2(2*node+1, mid+1, tr, gl, gr);
    return suma;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        cin >> a[i].first >> b[i].first;
        b[i].first++;
        a[i].second=b[i].second=i;
    }
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    for(int i=1; i<=m; i++) {
        cin >> q[i].l >> q[i].r >> q[i].w;
        q[i].k=i;
    }
    sort(q+1, q+m+1, nacin);
    int do1=0, do2=0;
    for(int i=1; i<=m; i++) {
        for(do1=do1+1; do1<=n; do1++) {
            if(a[do1].first>q[i].w) {
                do1--;
                break;
            }
            upd1(1, 1, n, a[do1].second);
        }
        for(do2=do2+1; do2<=n; do2++) {
            if(b[do2].first>q[i].w) {
                do2--;
                break;
            }
            upd2(1, 1, n, b[do2].second);
        }
        odg[q[i].k]=query1(1, 1, n, q[i].l, q[i].r)-query2(1, 1, n, q[i].l, q[i].r);
    }
    for(int i=1; i<=m; i++) cout << odg[i] << endl;
    return 0;
}