#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    long long n, m;
    cin >> n >> m;
    
    long long d, g;
    vector<vector<long long>> raspon;
    vector<long long> odgovori;

    for (long long i = 0; i < n; i++)
    {
        cin >> d >> g;
        raspon.push_back({ d, g });
    }

    long long l, r, x, answer;
    for (long long i = 0; i < m; i++)
    {
        cin >> l >> r >> x;
        answer = 0;
        for (long long j = l; j <= r; j++)
        {
            if (x >= raspon[j][0] && x <= raspon[j][1])
                ++answer;
            odgovori.push_back(answer);
        }
    }

    for (long long i = 0; i < m; i++)
    {
        cout << odgovori[i] << endl;
    }
}