#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> par;

int maxX = 310;

int main()
{
    int n, m, i, j, d, u, l, r, x;
    cin >> n >> m;
    int matrica[200000+1][maxX+1];
    for(i=0; i<=n; i++){for(j=0;j<=maxX;j++){matrica[i][j]=0;}}
    // STAMPANJE
    //for(i=0; i<=n; i++){for(j=0;j<=maxX;j++){cout << matrica[i][j] << " ";}cout << endl;}cout << endl;

    for(i=1; i<=n; i++)
    {
        cin >> d >> u;
        for(j=d;j<=u;j++)
        {
            matrica[i][j]=1;
        }
    }

    // STAMPANJE
    //for(i=0; i<=n; i++){for(j=0;j<=maxX;j++){cout << matrica[i][j] << " ";}cout << endl;}cout << endl;


    for(j=0;j<=maxX;j++)
    {
        for(i=2; i<=n; i++)
        {
            matrica[i][j] = matrica[i-1][j]+matrica[i][j];
        }
    }


    // STAMPANJE
    //for(i=0; i<=n; i++){for(j=0;j<=maxX;j++){cout << matrica[i][j] << " ";}cout << endl;}cout << endl;

    //for(i=1; i<=n; i++){cout << i << " " << vage[i].first << " " << vage[i].second << endl;}cout << endl;
    for(j=0; j<m; j++)
    {
        cin >> l >> r >> x;

        cout << matrica[r][x] - matrica[l-1][x] << endl;
    }
}