#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N = 500000 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> P(n), Q(m);
  for (auto& i : P) cin >> i.first >> i.second;
  for (auto& i : Q) cin >> i.first >> i.second;
  sort(P.begin(), P.end());
  int MAXLOG = 31 - __builtin_clz(N);
  vector<vector<int>> st(N, vector<int>(MAXLOG + 1));
  int j = 0;
  for (int i = 0; i < N; ++i) {
    st[i][0] = -1;
    if (i > 0 and st[i - 1][0] > i) st[i][0] = max(st[i][0], st[i - 1][0]);
    while (j < n and P[j].first <= i) {
      if (P[j].second > i) st[i][0] = max(st[i][0], P[j].second);
      ++j;
    }
  }
  for (int e = 1; e < MAXLOG + 1; ++e)
    for (int i = 0; i < N; ++i) {
      int j = st[i][e - 1];
      st[i][e] = (j == -1 ? -1 : st[j][e - 1]);
    }
  for (auto& q : Q) {
    int l = q.first, r = q.second;
    int count = 0;
    for (int e = MAXLOG; e >= 0; --e)
      if (st[l][e] != -1 and st[l][e] <= r) {
        l = st[l][e], count += 1 << e;
      }
    if (l < r and st[l][0] != -1) l = st[l][0], count++;
    if (l < r) count = -1;
    cout << count << '\n';
  }
  return 0;
}
