#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 7;
long long f[N][21];
int32_t main() {
  long long n, m;
  long long it = 0;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; ++i) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    f[x][0] = max(f[x][0], y);
    it = max(it, y);
  }
  for (long long i = 1; i <= it; ++i) f[i][0] = max(f[i - 1][0], f[i][0]);
  for (long long j = 1; j <= 20; ++j)
    for (long long i = 0; i <= it; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  for (long long j = 1; j <= m; ++j) {
    long long ans = 0, x, y;
    scanf("%lld%lld", &x, &y);
    for (long long i = 20; i >= 0; --i)
      if (f[x][i] < y) ans += 1 << i, x = f[x][i];
    printf("%lld\n", f[x][0] >= y ? ans + 1 : -1);
  }
  return 0;
}
