#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, M;
    int temp;
    vector<int> don, gor, l, d, tez, odgovori;
    cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        cin >> temp;
        don.push_back(temp);
        cin >> temp;
        gor.push_back(temp);
    }
    for(int i = 0; i < M; i++)
    {
        cin >> temp;
        l.push_back(temp - 1);
        cin >> temp;
        d.push_back(temp - 1);
        cin >> temp;
        tez.push_back(temp);
    }

    for(int i = 0; i < M; i++)
    {
        odgovori.push_back(0);
        for(int k = l[i] ; k <= d[i]; k++)
        {
            if(tez[i] >= don[k] && tez[i] <= gor[k])
            {
                odgovori[i] += 1;
            }
        }
    }

    for(int i = 0; i < M; i++)
    {
        cout << odgovori[i];
        if(i != M - 1)
            cout << "\n";
    }
    return 0;
}