#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 100, logN = 23;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int f[N][logN + 1];
int query(int l, int r) {
  long long 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() {
  int n = read(), m = read(), mx = 0;
  for (int i = 1; i <= n; ++i) {
    int l = read() + 1, r = read() + 1;
    f[l][0] = max(f[l][0], r);
    mx = max(mx, r);
  }
  for (int i = 1; i <= mx; ++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 <= mx; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  while (m--) {
    int l = read() + 1, r = read() + 1;
    printf("%d\n", query(l, r));
  }
  return 0;
}
