#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > best(500001, {-1, -1});
map<int, vector<pair<int, int> > > segs;
int lift[500001][25], r = 500001;
void dfs(int i) {
  if (best[i].first == -1) {
    for (int x = i + 1; x < r; x++) {
      if (best[x].first != -1) {
        dfs(x);
        return;
      }
    }
    return;
  }
  int t;
  for (t = i + 1; t < r and best[t].first == best[i].first; t++)
    ;
  if (t < r) {
    dfs(t);
    if (best[t].first == -1) r = t;
  }
  for (int l = i; l < t; l++) {
    lift[l][0] = best[i].second;
    for (int k = 1; k < 25; ++k) {
      lift[l][k] = min(r, lift[lift[l][k - 1]][k - 1]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  memset(lift, -1, sizeof(lift));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int L, R;
    cin >> L >> R;
    segs[L].emplace_back(R, i);
  }
  for (auto &P : segs) {
    sort(P.second.begin(), P.second.end());
    reverse(P.second.begin(), P.second.end());
  }
  int mxr = -1, mxi = -1;
  for (int i = 0; i < 500001; i++) {
    if (i >= mxr) {
      mxr = -1;
      mxi = -1;
    }
    if (!segs[i].empty()) {
      if (segs[i][0].first > mxr) {
        mxr = segs[i][0].first;
        mxi = segs[i][0].second;
      }
    }
    best[i] = {mxi, mxr};
  }
  for (int i = 0; i < 500001; i++) {
    if (best[i].first == -1) {
      for (int k = 0; k < 25; k++) lift[i][k] = i;
    }
  }
  dfs(0);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int z = x, ans = 0;
    bool ok = true;
    while (z < y) {
      int k;
      for (k = 0; k < 25; k++) {
        if (lift[z][k] >= y) {
          if (k > 0) {
            z = lift[z][k - 1];
            ans += (1 << (k - 1));
          } else {
            ans++;
            z = y;
          }
          break;
        }
      }
      if (k == 25) {
        ok = false;
        cout << "-1\n";
        break;
      }
    }
    if (ok) cout << ans << '\n';
  }
  return 0;
}
