#include <bits/stdc++.h>


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N , M;
    cin >> N >> M;
    map<long long, vector<long long>> REsenje;
    int a , b;
    for(int i = 1; i <= N; i++ )
    { 
        cin >> a >> b;
        for(int j = a; j <= b; j++)
        { 
            REsenje[j].push_back(i);
        }
    }
    long long l, r, masa;
    for(int i = 0; i < M; i++)
    { 
        cin >> l >> r >> masa;
        cout<< (upper_bound(REsenje[masa].begin(),REsenje[masa].end(), r) - REsenje[masa].begin()) - (lower_bound(REsenje[masa].begin(),REsenje[masa].end(), l) - REsenje[masa].begin()) << endl;
    }
    
    return 0;
}