#include <bits/stdc++.h>
const int N = 6e5 + 10;
int n, m, left, right, _max, otp, a[N], f[N][27];
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  scanf("%d %d", &n, &m);
  for (register int i = 1; i <= n; i++) {
    scanf("%d %d", &left, &right);
    a[left] = max(a[left], right);
    if (right > _max) _max = right;
  }
  for (register int i = 1; i <= _max; i++) a[i] = max(a[i], a[i - 1]);
  for (register int i = 0; i <= _max; i++) f[i][0] = a[i];
  for (register int i = 1; i <= 20; i++)
    for (register int j = 0; j <= _max; j++) f[j][i] = f[f[j][i - 1]][i - 1];
  while (m--) {
    otp = 1;
    scanf("%d %d", &left, &right);
    for (register int i = 20; i >= 0; i--)
      if (f[left][i] < right) {
        otp += 1 << i;
        left = f[left][i];
      }
    if (a[left] >= right)
      printf("%d", otp);
    else
      printf("-1");
    putchar(10);
  }
}
