#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n, a; cin >> n >> a; vector x(n); for (int i = 0; i < n; i++) { cin >> x[i]; } int t; cin >> t; vector> lri(t); for (int i = 0; i < t; i++) { int l, r; cin >> l >> r; lri[i] = make_tuple(l, r, i + 1); } sort(lri.begin(), lri.end()); vector ans(n); vector idx(n); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&](int i, int j) { return x[i] < x[j]; }); using pii = pair; priority_queue pq; int j = 0; for (int i : idx) { while (j < t && get<0>(lri[j]) <= x[i]) { pq.emplace(get<2>(lri[j]), get<1>(lri[j])); j++; } while (!pq.empty() && pq.top().second < x[i]) { pq.pop(); } if (!pq.empty()) { ans[i] = pq.top().first; } else { ans[i] = -1; } } for (int i = 0; i < n; i++) { cout << ans[i] << "\n"; } }