#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif #include int id() { return -1; } int mapping(int f, int x) { if (f != id()) return f; return x; } int comp(int f, int g) { return (f == id() ? g : f); } void solve() { int N, A; cin >> N >> A; vector> X(N); for (int i = 0; i < N; i++) { cin >> X[i].first; X[i].second = i; } sort(X.begin(), X.end()); vector Y(N); for (int i = 0; i < N; i++) Y[i] = X[i].first; atcoder::lazy_segtree seg(N); int T; cin >> T; for (int t = 1; t <= T; t++) { int L, R; cin >> L >> R; int l = distance(Y.begin(), lower_bound(Y.begin(), Y.end(), L)); int r = distance(Y.begin(), upper_bound(Y.begin(), Y.end(), R)); seg.apply(l, r, t); } vector ans(N); for (int i = 0; i < N; i++) ans[X[i].second] = seg.get(i); for (const auto& x : ans) cout << x << '\n'; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }