#include <bits/stdc++.h>
using namespace std;
const int N = 600005;
int n, m, l, r, ma, a[N], f[N][22];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    a[l] = max(a[l], r);
    ma = max(ma, r);
  }
  for (int i = 1; i <= ma; i++) a[i] = max(a[i], a[i - 1]);
  for (int i = 0; i <= ma; i++) f[i][0] = a[i];
  for (int i = 1; i <= 20; i++)
    for (int j = 0; j <= ma; j++) f[j][i] = f[f[j][i - 1]][i - 1];
  while (m--) {
    cin >> l >> r;
    int ans = 0;
    for (int i = 20; i >= 0; i--)
      if (f[l][i] < r) {
        ans += 1 << i;
        l = f[l][i];
      }
    if (a[l] >= r)
      printf("%d\n", ans + 1);
    else
      cout << -1 << '\n';
  }
  return 0;
}
