#include <bits/stdc++.h>
using namespace std;
const int siz = 500099;
int dp[26][siz], mx[siz];
int n, m, l[siz], r[siz];
int maxn;
void init() {
  maxn = 0;
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    maxn = max(maxn, r[i]);
    mx[l[i]] = max(mx[l[i]], r[i]);
  }
  dp[0][0] = mx[0];
  for (int i = 1; i <= maxn; i++) {
    mx[i] = max(mx[i - 1], mx[i]);
  }
  for (int i = 1; i <= maxn; i++) {
    dp[0][i] = mx[i];
  }
  for (int i = 1; i <= 20; i++) {
    for (int j = 0; j <= maxn; j++) {
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  }
}
int ask(int ll, int rr) {
  int ret = 0, p = ll;
  for (int i = 20; i >= 0; i--) {
    if (dp[i][p] < rr) {
      ret += (1 << i);
      p = dp[i][p];
    }
  }
  if (mx[p] >= rr)
    return ret + 1;
  else
    return -1;
}
int main() {
  ios::sync_with_stdio(0);
  int qqq;
  cin >> n >> m;
  qqq = m;
  init();
  int ll, rr;
  for (int it = 1; it <= qqq; it++) {
    cin >> ll >> rr;
    cout << ask(ll, rr) << endl;
  }
  return 0;
}
