#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout<<#x<< " = " << x << endl;
#define node tuple<int, int, int>
const int N = 2e5 + 3;
const ll MOD = 998244353;
const int INF = 1e9;
pair<int, int> vage[N];
unordered_map<int, int> ponavljanje[N];
int n, m;
//---------------------------------
namespace case1 {
    void solve(int l, int r, int x) {
        int cnt = 0;
        for (int i = l; i <= r; i++) {
            if (vage[i].first <= x && vage[i].second >= x)
                cnt++;
        }
        cout << cnt << "\n";
    }
}
namespace case2 {
    void solve(int l, int r, int x) {
        int formula = ponavljanje[r][x] - ponavljanje[l - 1][x];
        cout << formula << "\n";
    }
}
void precalc() {
    unordered_map<int, int> cur;
    for (int i = 1; i <= n; i++) {
        int d = vage[i].first, u = vage[i].second;
        for (int j = d; j <= u; j++) {
            cur[j]++;
        }
        ponavljanje[i] = cur;
    }
}


int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> vage[i].first >> vage[i].second;
    }
    precalc();

    for (int i = 0; i < m; i++) {
        int l, r, x; cin >> l >> r >> x;
        if (n <= 1000 && m <= 1000)
            case1::solve(l, r, x);
        else {
            case2::solve(l, r, x);
        }
    }

    return 0;
}
/*
8 9
1 3 1
1 2 1
2 4 1
2 5 0
3 5 1
5 6 1
6 8 0
3 7 0
7 8 1
1 8
*/