#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, x, k, ans, nx[500050][22];
long long a[500050];
vector<pair<long long, long long> > v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a[x] = max(y, a[x]);
  }
  for (int i = 0; i < 500010; i++)
    a[i] = max(a[i], a[i - 1]), nx[i][0] = max(a[i], (long long)i);
  for (int j = 1; j < 21; j++)
    for (int i = 0; i < 500010; i++) nx[i][j] = nx[nx[i][j - 1]][j - 1];
  for (int it = 0; it < m; it++) {
    long long x, y;
    cin >> x >> y;
    if (nx[x][20] < y) {
      cout << "-1\n";
      continue;
    }
    long long ans = 1;
    for (int i = 19; i > -1; i--)
      if (nx[x][i] < y) {
        ans += (1 << i);
        x = nx[x][i];
      }
    cout << ans << "\n";
  }
  return 0;
}
