#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int dp[N][30], n, m;
int main() {
  scanf("%d%d", &n, &m);
  while (n--) {
    int l, r;
    scanf("%d%d", &l, &r);
    dp[l][0] = max(dp[l][0], r);
  }
  for (int i = 1; i < N; i++) dp[i][0] = max(dp[i][0], dp[i - 1][0]);
  for (int k = 1; k <= 20; k++)
    for (int i = 0; i < N; i++) dp[i][k] = dp[dp[i][k - 1]][k - 1];
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = 0;
    for (int k = 19; k >= 0; k--)
      if (dp[l][k] < r) ans ^= (1 << k), l = dp[l][k];
    if (dp[l][0] < r)
      puts("-1");
    else
      printf("%d\n", ans + 1);
  }
  return 0;
}
