#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
long long a[500001][22];
void solve() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 0; i <= 500000; i++) {
    a[i][0] = i;
  }
  for (long long i = 1; i <= n; i++) {
    long long l, r;
    cin >> l >> r;
    a[l][0] = max(a[l][0], r);
  }
  for (long long i = 1; i <= 500000; i++) {
    a[i][0] = max(a[i][0], a[i - 1][0]);
  }
  for (long long j = 1; j <= 21; j++) {
    for (long long i = 0; i <= 500000; i++) {
      a[i][j] = a[a[i][j - 1]][j - 1];
    }
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    if (a[l][21] < r) {
      cout << -1 << "\n";
      continue;
    }
    long long low = 0, high = 500001;
    while (low + 1 < high) {
      long long mid = (low + high) / 2;
      long long now = l;
      for (long long j = 21; j >= 0; j--) {
        if (mid & (1 << j)) {
          now = a[now][j];
        }
      }
      if (now >= r) {
        high = mid;
      } else {
        low = mid;
      }
    }
    cout << high << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
