#include <bits/stdc++.h>
using namespace std;
const int Maxn = 5e5 + 10;
int a[Maxn];
int b[Maxn][20];
int main() {
  int n, m, l, r;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    a[l] = max(a[l], r);
  }
  b[0][0] = a[0];
  for (int i = 1; i < Maxn; i++) {
    a[i] = max(a[i], a[i - 1]);
    b[i][0] = a[i];
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < Maxn; i++) {
      b[i][j] = b[b[i][j - 1]][j - 1];
    }
  }
  int ans = 0;
  while (m--) {
    scanf("%d%d", &l, &r);
    ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (b[l][i] < r) {
        ans += (1 << i);
        l = b[l][i];
      }
    }
    if (b[l][0] >= r) {
      printf("%d\n", ans + 1);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
