#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MX = 5e5 + 5;
const int LG = 20;
int n, m;
int par[MX][LG], nxt[MX];
void SetSparse() {
  int i, j, k;
  int cur = 0;
  for (i = 0; i < MX; ++i) {
    cur = max({cur, i, nxt[i]});
    par[i][0] = cur;
  }
  for (i = 1; i < LG; ++i) {
    for (j = 0; j < MX; ++j) {
      par[j][i] = par[par[j][i - 1]][i - 1];
    }
  }
}
bool CanGo(int l, int r, int steps) {
  int i, j, k;
  int cur = l;
  for (i = 0; i < LG; ++i) {
    if (steps & (1 << i)) {
      cur = par[cur][i];
    }
  }
  return cur >= r;
}
int main() {
  int i, j, k;
  scanf("%d %d", &n, &m);
  int l, r;
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &l, &r);
    nxt[l] = max(nxt[l], r);
  }
  SetSparse();
  while (m--) {
    scanf("%d %d", &l, &r);
    int low = 0, high = n, mid, ans = -1;
    while (high >= low) {
      mid = (low + high) / 2;
      if (CanGo(l, r, mid)) {
        ans = mid;
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    }
    printf("%d\n", ans);
  }
}
