#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> ranges(N + 1);

  for (int i = 1; i <= N; i++)
  {
    cin >> ranges[i].first >> ranges[i].second;
  }

  for (int i = 0; i < M; i++)
  {
    int l, r, x;
    cin >> l >> r >> x;

    int c = 0;

    for (int j = l; j <= r; j++)
    {
      c += ((ranges[j].first <= x) && (x <= ranges[j].second));
    }

    cout << c << "\n";
  }
}