cin >> n >> m; for (int i = 1; i <= n; ++i) { int x, y; cin >> x >> y; p[x] = max(p[x], y); } for (int i = 1; i <= N; ++i) p[i] = max(p[i], p[i - 1]); for (int i = 1; i <= N; ++i) nxt[i][0] = p[i]; for (int j = 1; j <= 20; ++j) for (int i = 1; i <= N; ++i) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; while (m--) { int x, y, p, ans = 0; cin >> x >> y; p = x; for (int i = 1; ~i; --i) if (nxt[p][i] && nxt[p][i] < y) p = nxt[p][i], ans += 1 << i; cout << (nxt[p][0] >= y ? ans + 1 : -1) << "\n"; } return0; }