#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int nxt[maxn];
int n, ans, m, l, r;
int rmq[maxn][30];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> l >> r;
    nxt[l] = max(nxt[l], r);
  }
  for (int i = 0; i < maxn; i++) {
    nxt[i] = max(nxt[i], nxt[i - 1]);
    nxt[i] = max(nxt[i], i);
    rmq[i][0] = nxt[i];
  }
  for (int i = 1; i <= 25; i++)
    for (int j = 0; j < maxn; j++) {
      rmq[j][i] = max(rmq[j][i - 1], rmq[rmq[j][i - 1]][i - 1]);
    }
  for (int i = 1; i <= m; i++) {
    cin >> l >> r;
    ans = 0;
    for (int j = 25; j >= 0; j--) {
      if (rmq[l][j] < r) {
        l = rmq[l][j];
        ans = ans + (1 << j);
      }
    }
    if (l < r) {
      l = rmq[l][0];
      ans++;
    }
    if (l >= r)
      cout << ans << '\n';
    else
      cout << -1 << '\n';
  }
}
