#include <bits/stdc++.h>
using namespace std;
int n, m;
int tab[500005];
int nxt[500005][20];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  vector<pair<int, int> > eh(n);
  for (int i = 0; i < (n); ++i) {
    int t1, t2;
    cin >> t1 >> t2;
    t1++;
    t2++;
    nxt[t1][0] = max(nxt[t1][0], t2);
  }
  int mx = 0;
  for (int i = 0; i < (500005); ++i) {
    mx = max(nxt[i][0], mx);
    if (mx > i) nxt[i][0] = mx;
  }
  for (int k = 1; k <= (19); k++) {
    for (int i = 0; i < (500005); ++i) nxt[i][k] = nxt[nxt[i][k - 1]][k - 1];
  }
  for (int i = 0; i < (m); ++i) {
    int t1, t2;
    cin >> t1 >> t2;
    t1++;
    t2++;
    int sum = 0;
    for (int k = 19; k >= (0); k--) {
      if (nxt[t1][k] < t2 && nxt[t1][k] != 0 && nxt[t1][k] != t1) {
        sum += 1 << k;
        t1 = nxt[t1][k];
      }
    }
    t1 = nxt[t1][0];
    sum++;
    cout << ((t1 >= t2) ? sum : -1) << "\n";
  }
  return 0;
}
