#include <bits/stdc++.h>
using namespace std;
int a[500005], f[500005][25];
int main() {
  int n, m, mx = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    mx = max(mx, r);
    a[l] = max(a[l], r);
  }
  for (int i = 1; i <= mx; i++) a[i] = max(a[i], a[i - 1]);
  for (int i = 0; i <= mx; i++) f[i][0] = a[i];
  for (int i = 1; i <= 20; i++)
    for (int j = 0; j <= mx; j++) f[j][i] = f[f[j][i - 1]][i - 1];
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = 0;
    for (int i = 20; i >= 0; i--)
      if (f[x][i] < y) {
        ans += 1 << i;
        x = f[x][i];
      }
    if (a[x] >= y)
      printf("%d\n", ans + 1);
    else
      printf("-1\n");
  }
  return 0;
}
