#include <iostream>
using namespace std;

struct vaga {
    int donja, gornja;
};
struct pitanja {
    int l, r, x;
};
int main()
{
    int n, m;
    cin >> n >> m;
    vaga* nVaga = new vaga[n];
    pitanja* mPitanja = new pitanja[m];
    int* odgovor = new int[m];
    for (int i = 0; i < n; i++) {
        cin >> nVaga[i].donja >> nVaga[i].gornja;
    }
    for (int i = 0; i < m; i++) odgovor[i] = 0;
    for (int i = 0; i < m; i++) {
        cin >> mPitanja[i].l >> mPitanja[i].r >> mPitanja[i].x;

        for (int j = mPitanja[i].l; j <= mPitanja[i].r; j++) {
            if (nVaga[j-1].donja <= mPitanja[i].x && nVaga[j-1].gornja >= mPitanja[i].x)odgovor[i]++;

        }

    }
    for (int i = 0; i < m; i++) {
        cout << odgovor[i]<<"\n";
    }
    delete[]odgovor;
    delete[]nVaga;
    delete[]mPitanja;
}