#include <bits/stdc++.h>
using namespace std;
int l[600050], f[500050][22];
int main() {
  int n, m;
  cin >> n >> m;
  int tot = 0;
  for (int i = 1, a, b; i <= n; i++) {
    scanf("%d%d", &a, &b);
    l[a] = max(l[a], b);
    tot = max(tot, b);
  }
  for (int i = 1; i <= tot; i++) l[i] = max(l[i], l[i - 1]);
  for (int i = 0; i <= tot; i++) f[i][0] = l[i];
  for (int i = 1; i <= 20; i++) {
    for (int j = 0; j <= tot; j++) {
      f[j][i] = f[f[j][i - 1]][i - 1];
    }
  }
  int a, b;
  while (m--) {
    int ans = 0;
    scanf("%d%d", &a, &b);
    for (int i = 20; i >= 0; i--) {
      if (f[a][i] < b) {
        ans += 1 << i;
        a = f[a][i];
      }
    }
    if (l[a] >= b)
      printf("%d\n", ans + 1);
    else
      printf("-1\n");
  }
  return 0;
}
