#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0) {
    putchar('-'), write(-x);
  } else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 5e5 + 5;
int n, m, a[N], ma, f[N][20];
signed main() {
  read(n);
  read(m);
  for (int i = 1, l, r; i <= n; i++) {
    read(l);
    read(r);
    a[l] = max(a[l], r);
    ma = max(ma, r);
  }
  for (int i = 1; i <= ma; i++) a[i] = max(a[i], a[i - 1]);
  for (int i = 0; i <= ma; i++) f[i][0] = a[i];
  for (int j = 1; j <= 18; j++)
    for (int i = 0; i <= ma; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  while (m--) {
    int l, r, ans = 0;
    read(l);
    read(r);
    for (int i = 18; i >= 0; i--)
      if (f[l][i] < r) {
        ans += 1 << i;
        l = f[l][i];
      }
    if (a[l] >= r)
      write(ans + 1);
    else
      write(-1);
    puts("");
  }
}
