#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, lim = 5e5;
pair<int, int> a[N];
int f[N][21], lg2[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[i] = make_pair(x, y);
  }
  sort(a + 1, a + n + 1);
  for (int i = 0, j = 1, r = 0; i <= lim; i++) {
    while (j <= n && a[j].first <= i) r = max(r, a[j].second), j++;
    f[i][0] = max(i, r);
  }
  lg2[1] = 0;
  for (int i = 2; i <= lim; i++) lg2[i] = lg2[i >> 1] + 1;
  for (int k = 1; k <= lg2[lim]; k++)
    for (int i = 0; i <= lim; i++) f[i][k] = f[f[i][k - 1]][k - 1];
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = 0;
    for (int k = lg2[y - x]; x < y; k ? k-- : 0) {
      if (f[x][k] == x && x < y) {
        ans = -1;
        break;
      }
      while (k && f[x][k] >= y) k--;
      ans += 1 << k;
      x = f[x][k];
    }
    printf("%d\n", ans);
  }
  return 0;
}
