#include <bits/stdc++.h>
using namespace std;
const char IO_MODE = 3;
inline long long ReadInt() {
  long long x = 0, s = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') s = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return s * x;
}
inline void WriteInt(long long x) {
  char c[20];
  if (!x) {
    putchar('0');
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int i = 0;
  while (x > 0) c[++i] = x % 10, x /= 10;
  while (i) putchar(c[i--] + 48);
}
template <typename T>
inline void out(T x) {
  if (IO_MODE & 1)
    WriteInt(x);
  else if (typeid(x) == typeid(int))
    printf("%i", x);
  else
    printf("%lld", (long long)x);
}
template <typename T, typename... Args>
inline void out(T x, Args... args) {
  out(x);
  putc(' ', stdout);
  out(args...);
}
template <typename T>
inline void in(T &x) {
  if (IO_MODE & 2)
    x = ReadInt();
  else if (typeid(x) == typeid(int))
    scanf("%i", &x);
  else if (typeid(x) == typeid(long long))
    scanf("%lld", &x);
}
template <typename T, typename... Args>
inline void in(T &x, Args &...args) {
  in(x);
  in(args...);
}
int aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm, nn, oo, pp, qq, rr, ss, tt,
    uu, vv, ww, xx, yy, zz;
int tc;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
int n, m;
int M[20][500100];
int main() {
  in(n, m);
  for (int i = 0; i < n; i++) {
    int l = ReadInt() + 1, r = ReadInt() + 1;
    M[0][l] = max(M[0][l], r);
  }
  for (int i = 0; i < 500100; i++) {
    static int mx = 0;
    mx = max(mx, M[0][i]);
    M[0][i] = mx;
    if (M[0][i] < i) M[0][i] = 0;
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < 500100; i++) {
      M[j][i] = M[j - 1][M[j - 1][i]];
    }
  }
  for (int i = 0; i < m; i++) {
    int l = ReadInt() + 1, r = ReadInt() + 1;
    int ans = 0;
    for (int j = 19; j >= 0; j--)
      if (M[j][l] < r) ans += 1 << j, l = M[j][l];
    l = M[0][l], ans++;
    if (l < r)
      printf("-1\n");
    else
      printf("%d\n", ans);
  }
}
