#include <bits/stdc++.h>
using namespace std;
int n, m, mxR[500005], table[500005][20];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    mxR[l] = max(mxR[l], r);
  }
  memset(table, -1, sizeof table);
  for (int i = 1; i < 500005; i++) {
    mxR[i] = max(mxR[i], mxR[i - 1]);
  }
  for (int i = 0; i < 500005; i++) {
    if (mxR[i] > i) table[i][0] = mxR[i];
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 0; j < 500005; j++) {
      if (table[j][i - 1] == -1) continue;
      table[j][i] = table[table[j][i - 1]][i - 1];
    }
  }
  while (m--) {
    int l, r;
    cin >> l >> r;
    int ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (table[l][i] == -1) continue;
      if (table[l][i] < r) {
        ans += (1 << i);
        l = table[l][i];
      }
    }
    if (table[l][0] >= r)
      cout << ans + 1 << '\n';
    else
      cout << "-1\n";
  }
  return 0;
}
