#include <bits/stdc++.h>
const int32_t MAX_X = 5e5;
const int32_t LOG_MAX_N = 20;
int32_t p[MAX_X + 5], sparseTable[MAX_X + 5][LOG_MAX_N + 5];
void build_sparse_table() {
  int32_t currMaxEnd = -1;
  memset(sparseTable, -1, sizeof(sparseTable));
  for (int32_t i = 0; i <= MAX_X; i++) {
    currMaxEnd = std::max(currMaxEnd, p[i]);
    sparseTable[i][0] = (currMaxEnd > i ? currMaxEnd : -1);
  }
  for (int32_t j = 1; j <= LOG_MAX_N; j++) {
    for (int32_t i = 0; i <= MAX_X; i++) {
      if (sparseTable[i][j - 1] != -1) {
        sparseTable[i][j] = sparseTable[sparseTable[i][j - 1]][j - 1];
      }
    }
  }
}
int32_t answer_query(int32_t low, int32_t high) {
  int32_t ans = 0;
  for (int32_t j = LOG_MAX_N; j >= 0; j--) {
    if (sparseTable[low][j] != -1 && sparseTable[low][j] <= high) {
      low = sparseTable[low][j];
      ans += (1 << j);
    }
  }
  if (low < high) {
    low = sparseTable[low][0];
    ans++;
  }
  if (low == -1) {
    return -1;
  }
  return ans;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int32_t n, m;
  std::cin >> n >> m;
  memset(p, -1, sizeof(p));
  for (int32_t i = 0; i < n; i++) {
    int32_t l, r;
    std::cin >> l >> r;
    p[l] = std::max(p[l], r);
  }
  build_sparse_table();
  for (int32_t i = 0; i < m; i++) {
    int32_t low, high;
    std::cin >> low >> high;
    std::cout << answer_query(low, high) << '\n';
  }
}
