#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
const int LOGN = 23;
int n, m;
int f[N][LOGN + 1];
int maxx;
int query(int l, int r) {
  int ans = 0;
  for (int i = LOGN - 1; i >= 0; --i) {
    if (f[l][i] < r) {
      l = f[l][i];
      ans += (1 << i);
    }
  }
  l = f[l][0];
  ++ans;
  if (l < r) return -1;
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  int l, r;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l, &r);
    ++l, ++r;
    f[l][0] = max(f[l][0], r);
    maxx = max(maxx, r);
  }
  for (int i = 1; i <= maxx; ++i) f[i][0] = max(f[i][0], max(i, f[i - 1][0]));
  for (int j = 1; j < LOGN; ++j)
    for (int i = 1; i <= maxx; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  while (m--) {
    scanf("%d%d", &l, &r);
    ++l, ++r;
    printf("%d\n", query(l, r));
  }
  return 0;
}
