#include <bits/stdc++.h>
using namespace std;
const int chang = 500010;
int n, b, k, m;
int lc[22][chang], R[chang];
void bian() {
  for (int i = 1; i < 21; i++) {
    for (int j = 0; j < chang; j++) {
      lc[i][j] = lc[i - 1][lc[i - 1][j]];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    R[l] = max(r, R[l]);
  }
  for (int i = 1; i < chang; i++) {
    R[i] = max(R[i], R[i - 1]);
    lc[0][i] = R[i];
  }
  lc[0][0] = R[0];
  bian();
  for (int i = 1; i <= m; i++) {
    int x, y, ans = 0;
    scanf("%d%d", &x, &y);
    for (int i = 19; i >= 0; i--) {
      if (lc[i][x] < y) {
        ans += (1 << i);
        x = lc[i][x];
      }
    }
    if (lc[0][x] >= y)
      printf("%d\n", ans + 1);
    else
      printf("-1\n");
  }
}
