#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
int n, m;
int maxr, nxt[maxn], dp[maxn][22];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    nxt[l] = max(nxt[l], r);
    maxr = max(maxr, r);
  }
  for (int i = 1; i <= maxr; i++) nxt[i] = max(nxt[i], nxt[i - 1]);
  for (int i = 0; i <= maxr; i++) dp[i][0] = nxt[i];
  for (int i = 1; i <= 20; i++) {
    for (int j = 0; j <= maxr; j++) {
      dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = 0;
    for (int i = 20; i >= 0; i--) {
      if (dp[l][i] < r) {
        ans += (1 << i);
        l = dp[l][i];
      }
    }
    if (nxt[l] >= r)
      printf("%d\n", ans + 1);
    else
      puts("-1");
  }
  return 0;
}
