#include <bits/stdc++.h>
using namespace std;
int n, m, t, now, lim, f[500005][24], ans, a1, a2;
struct node {
  int a, b;
} s[500005];
int gets() {
  int v = 0;
  char ch;
  bool f = 0;
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = 1;
  v = ch - 48;
  while (isdigit(ch = getchar())) v = (v << 1) + (v << 3) + ch - 48;
  return f ? -v : v;
}
bool cmp(const node &x, const node &y) {
  return x.a == y.a ? x.b < y.b : x.a < y.a;
}
int main() {
  n = gets();
  m = gets();
  for (int i = 1; i <= n; i++)
    s[i].a = gets() + 1, s[i].b = gets() + 1, lim = max(lim, s[i].b);
  sort(1 + s, 1 + s + n, cmp);
  t = 1;
  for (int i = 1; i <= lim; i++) {
    while (s[t].a <= i && t <= n) now = max(now, s[t].b), t++;
    f[i][0] = now;
  }
  for (int j = 1; j <= 21; j++)
    for (int i = 1; i <= lim; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  for (int i = 1; i <= m; i++) {
    a1 = gets() + 1, a2 = gets() + 1;
    ans = 0;
    for (int j = 21; j >= 0; j--) {
      if (f[a1][j] < a2) ans += (1 << j), a1 = f[a1][j];
    }
    a1 = f[a1][0];
    ans++;
    if (a1 >= a2)
      printf("%d\n", ans);
    else
      puts("-1");
  }
  return 0;
}
