#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265359;
const long long MOD = (long long)16033;
const long long delta = 16033;
const long long MAXN = (long long)5e5 + 10;
const long long INF = (long long)(1ll << 32);
const long double EPS = (long double)1e-8;
const long long LOG = (long long)22;
vector<long long> seg[MAXN];
long long nx[MAXN + 10];
long long sp[MAXN + 10][LOG];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long l, r;
  for (int i = 1; i <= n; i++) {
    cin >> l >> r;
    seg[l].push_back(r);
  }
  long long mx = -1;
  for (int i = 0; i < MAXN; i++) {
    for (auto x : seg[i]) mx = max(mx, x);
    if (mx >= i)
      nx[i] = mx;
    else
      nx[i] = i;
  }
  for (int i = 0; i < MAXN; i++) {
    sp[i][0] = nx[i];
  }
  for (int lg = 1; lg < LOG; lg++) {
    for (int i = 0; i < MAXN; i++) {
      sp[i][lg] = sp[sp[i][lg - 1]][lg - 1];
    }
  }
  long long x, y, ans;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (sp[x][LOG - 1] < y) {
      cout << -1 << '\n';
      continue;
    }
    ans = 0;
    for (int lg = LOG - 1; lg >= 0; lg--) {
      if (sp[x][lg] < y) {
        ans += (1ll << lg);
        x = sp[x][lg];
      }
    }
    cout << ans + 1 << '\n';
  }
  return 0;
}
