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