#include <bits/stdc++.h>
using namespace std;
int nx[21][600000];
int main() {
  int n, m;
  cin >> n >> m;
  int N = 500001;
  vector<pair<int, int> > v;
  for (int i = 0; i < (n); i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    v.push_back(pair<int, int>(l, r));
  }
  sort(v.begin(), v.end());
  int s = 0;
  int Max = 0;
  for (int i = 0; i < (N); i++) {
    while (s < v.size() && v[s].first <= i) {
      Max = max(Max, v[s++].second);
    }
    nx[0][i] = max(i, Max);
  }
  for (int i = 1; i <= 20; i++)
    for (int j = 0; j < (N); j++) {
      nx[i][j] = nx[i - 1][nx[i - 1][j]];
    }
  for (int i = 0; i < (m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int pos = x;
    int cnt = 0;
    for (int i = 20; i >= 0; i--) {
      if (nx[i][pos] < y) pos = nx[i][pos], cnt += (1 << i);
    }
    if (nx[0][pos] < y) {
      puts("-1");
    } else
      printf("%d\n", cnt + 1);
  }
}
