#include <bits/stdc++.h>
using namespace std;
const int maxn = 500050;
int n, m, limit;
int a[maxn];
int f[maxn][22];
int main() {
  memset(f, 0, sizeof(f));
  cin >> n >> m;
  limit = -1;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x] = max(a[x], y);
    limit = max(limit, y);
  }
  for (int i = 1; i <= limit; i++) a[i] = max(a[i - 1], a[i]);
  for (int i = 0; i <= limit; i++) f[i][0] = a[i];
  for (int j = 1; j <= 20; j++)
    for (int i = 0; i <= limit; i++) {
      if (f[i][j - 1] == -1) {
        f[i][j] = -1;
        continue;
      }
      if (f[f[i][j - 1]][j - 1] == f[i][j - 1])
        f[i][j] = -1;
      else
        f[i][j] = f[f[i][j - 1]][j - 1];
    }
  int ans, now;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ans = 0, now = x;
    for (int j = 20; j >= 0; j--) {
      if (f[now][j] <= y && f[now][j] != -1) {
        ans += 1 << j;
        now = f[now][j];
        if (now == y) break;
      }
    }
    if (now == y)
      cout << ans << endl;
    else if (f[now][0] > y)
      cout << ++ans << endl;
    else
      puts("-1");
  }
}
