#include <bits/stdc++.h>
using namespace std;
int read() {
  char s;
  int x = 0, f = 1;
  s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x *= 10;
    x += s - '0';
    s = getchar();
  }
  return x * f;
}
int n, m;
int a[500001];
int p[500001][21];
int main() {
  n = read();
  m = read();
  int maxn = -1;
  for (int i = 1; i <= n; i++) {
    int l, r;
    l = read();
    r = read();
    a[l] = max(a[l], r);
    maxn = max(maxn, r);
  }
  for (int i = 1; i <= maxn; i++) {
    a[i] = max(a[i], a[i - 1]);
    p[i][0] = a[i];
  }
  p[0][0] = a[0];
  for (int j = 1; j <= 20; j++) {
    for (int i = 0; i <= maxn; i++) {
      p[i][j] = p[p[i][j - 1]][j - 1];
    }
  }
  for (int i = 1; i <= m; i++) {
    int ans = 0;
    int l, r;
    l = read();
    r = read();
    for (int j = 20; j >= 0; j--) {
      if (p[l][j] < r) {
        ans += (1 << j);
        l = p[l][j];
      }
    }
    if (a[l] >= r)
      cout << ans + 1 << endl;
    else
      cout << -1 << endl;
  }
}
