#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 3;
const long long MOD = (int)1e9 + 7;
const long long inf = (long long)1e13;
const int infint = (int)1e9 + 3;
int sp[20][MAXN], n, m, l[MAXN], r[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < MAXN; i++) sp[0][i] = i;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    sp[0][l[i]] = max(sp[0][l[i]], r[i]);
  }
  for (int i = 1; i < MAXN; i++) sp[0][i] = max(sp[0][i - 1], sp[0][i]);
  for (int i = 1; i < 20; i++)
    for (int j = 0; j < MAXN; j++) sp[i][j] = sp[i - 1][sp[i - 1][j]];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int ans = 0, cur = x;
    for (int i = 19; i >= 0; i--) cur = sp[i][cur];
    if (cur < y) {
      cout << -1 << "\n";
      continue;
    }
    for (int i = 19; i >= 0; i--)
      if (sp[i][x] < y) x = sp[i][x], ans += 1 << i;
    cout << ans + 1 << "\n";
  }
}
