#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <time.h>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <windows.h>

using namespace std;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::ifstream;
using std::istringstream;
using std::ostringstream;
using std::string;
using std::stringstream;
using std::vector;

class vaga
{
public:
    int min, max;
    vaga(int d, int u)
    {
        min = d;
        max = u;
    }
    bool canWeight(int x)
    {
        return x <= max && x >= min;
    }
};
class pitanje
{
public:
    int l, r, x;
    pitanje(int ll, int rr, int xx)
    {
        l = ll - 1;
        r = rr - 1;
        x = xx;
    }
    int countPossible(vector<vaga> sveVage)
    {
        int count = 0;
        for (int i = l; i < r + 1; i++)
        {
            if (sveVage[i].canWeight(x))
                count++;
        }
        return count;
    }
};

int main(void)
{
    int N, M;
    vector<vaga> sveVage;
    vector<pitanje> svaPitanja;

    // intput
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        int di, ui;
        cin >> di >> ui;
        vaga temp(di, ui);
        sveVage.push_back(temp);
    }
    for (int i = 0; i < M; i++)
    {
        int ll, rr, xx;
        cin >> ll >> rr >> xx;
        pitanje temp(ll, rr, xx);
        svaPitanja.push_back(temp);
    }
    // end of input

    // output
    for (int i = 0; i < M; i++)
    {
        cout << svaPitanja[i].countPossible(sveVage) << endl;
    }
    //  end of output

    return 0;
}