#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int nxt[25][N];
int query(int x, int y) {
  int seg = 0;
  for (int i = 24; i >= 0; i--) {
    if (nxt[i][x] < y) {
      seg += (1 << i);
      x = nxt[i][x];
    }
  }
  if (seg >= (1 << 24)) return -1;
  return seg + 1;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    nxt[0][l] = max(nxt[0][l], r);
  }
  for (int i = 1; i < N; i++) {
    nxt[0][i] = max(nxt[0][i], nxt[0][i - 1]);
  }
  for (int i = 1; i <= 24; i++) {
    for (int j = 0; j < N; j++) {
      nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
    }
  }
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", query(x, y));
  }
}
