#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int v[500005];
int to[500005][20];
int main() {
  cin.sync_with_stdio(false), cin.tie(nullptr);
  iota(v, v + 500005, 0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    v[l] = max(v[l], r);
  }
  for (int i = 0; i < 20; i++) {
    to[500000][i] = 500000;
  }
  for (int i = 0; i < 500000; i++) {
    to[i][0] = v[i];
    if (i > 0) {
      to[i][0] = max(to[i][0], to[i - 1][0]);
    }
  }
  for (int i = 500000 - 1; i >= 0; i--) {
    for (int j = 1; j < 20; j++) {
      to[i][j] = to[to[i][j - 1]][j - 1];
    }
  }
  while (m--) {
    int x, y;
    cin >> x >> y;
    int res = 0;
    for (int i = 19; i >= 0; i--) {
      if (to[x][i] < y) {
        res |= (1 << i), x = to[x][i];
      }
    }
    if (to[x][0] >= y) {
      cout << res + 1 << "\n";
    } else {
      cout << "-1\n";
    }
  }
}
