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