#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 200005;
const long long MaxR = 500000;
const long long MaxST = 22;
template <class t>
inline void rd(t &s) {
  s = 0;
  register char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  return;
}
long long _log2[MaxR + 5];
inline void Init_log2() {
  _log2[1] = 0, _log2[2] = 1;
  for (long long i = 3; i <= MaxR; ++i) _log2[i] = _log2[i >> 1] + 1;
  return;
}
long long max_dis[MaxR + 5];
long long st[MaxR + 5][MaxST];
signed main(void) {
  Init_log2();
  register long long l, r, ans;
  long long n, m;
  rd(n);
  rd(m);
  for (long long i = 1; i <= n; ++i) {
    rd(l);
    rd(r);
    max_dis[l] = max(max_dis[l], r);
  }
  st[0][0] = max_dis[0];
  for (long long i = 1; i <= MaxR; ++i) {
    max_dis[i] = max(max_dis[i], max_dis[i - 1]);
    st[i][0] = max_dis[i];
  }
  for (long long j = 1; j <= _log2[n] + 1; ++j)
    for (long long i = 0; i <= MaxR; ++i) st[i][j] = st[st[i][j - 1]][j - 1];
  for (long long i = 1; i <= m; ++i) {
    ans = 0;
    rd(l);
    rd(r);
    for (long long i = _log2[n] + 1; i >= 0; --i)
      if (st[l][i] < r) {
        ans += (1 << i);
        l = st[l][i];
      }
    if (max_dis[l] >= r)
      ++ans;
    else
      ans = -1;
    printf("%lld\n", ans);
  }
  return 0;
}
