#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> ar[500010];
int mr[500010];
vector<pair<int, int> > v;
int up[20][500010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> ar[i].first >> ar[i].second;
    mr[ar[i].first] = max(mr[ar[i].first], ar[i].second);
  }
  for (int i = 1; i < 500010; i++) {
    mr[i] = max(mr[i], mr[i - 1]);
  }
  for (int i = 0; i < 500010; i++) {
    if (mr[i] <= i) continue;
    up[0][i] = mr[i];
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 0; j < 500010; j++) {
      if (up[i - 1][j] <= j) continue;
      up[i][j] = up[i - 1][up[i - 1][j]];
    }
  }
  while (m--) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (up[i][a] <= a) continue;
      if (up[i][a] <= b) {
        ans += (1 << i);
        a = up[i][a];
      }
    }
    if (up[0][a] >= b && a < b)
      cout << ans + 1 << '\n';
    else if (a < b)
      cout << -1 << '\n';
    else
      cout << ans << '\n';
  }
  return 0;
}
