#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 100;
const int maxm = 2e6 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
int f[maxn][25];
int ask(int l, int r) {
  long long ans = 0;
  for (int i = 24; 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 n, m;
int main() {
  scanf("%d %d", &n, &m);
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    l++;
    r++;
    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 < 25; j++) {
    for (int i = 1; i <= mx; i++) {
      f[i][j] = f[f[i][j - 1]][j - 1];
    }
  }
  while (m--) {
    int l, r;
    scanf("%d %d", &l, &r);
    l++;
    r++;
    printf("%d\n", ask(l, r));
  }
  return 0;
}
