#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }

    for (int i = 0; i < m; i++)
    {
        int a, b, x;
        cin >> a >> b >> x;
        int brojVaga = 0;
        for (int j = a; j <= b; j++)
            if(x >= v[j].first && x <= v[j].second)
                brojVaga++;
        cout << brojVaga;
    }
}