#include <bits/stdc++.h>
const int MAXL = 500005;
const int MAXN_LOG = 20;
int maxr[MAXN_LOG][MAXL];
void init(int n) {
  for (int i = 1; i < MAXN_LOG; i++) {
    for (int j = 1; j <= n; j++)
      maxr[i - 1][j] = std::max(maxr[i - 1][j], maxr[i - 1][j - 1]);
    for (int j = 0; j <= n; j++)
      maxr[i][j] = maxr[i - 1][j] == -1 ? -1 : maxr[i - 1][maxr[i - 1][j]];
  }
}
int main() {
  for (int i = 0; i < MAXN_LOG; i++) std::fill(maxr[i], maxr[i] + MAXL, -1);
  int n, q, maxp = 0;
  scanf("%d %d", &n, &q);
  for (int i = 0, l, r; i < n; i++) {
    scanf("%d %d", &l, &r);
    maxr[0][l] = std::max(maxr[0][l], r);
    maxp = std::max(maxp, r);
  }
  init(maxp);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    int ans = 0;
    for (int i = MAXN_LOG - 2; ~i; i--) {
      if (maxr[i][l] < r) {
        ans += 1 << i;
        l = maxr[i][l];
      }
    }
    l = maxr[0][l];
    ans = l < r ? -1 : ans + 1;
    printf("%d\n", ans);
  }
  return 0;
}
