#include #include using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector tp(Q); vector x(Q), y(Q); for (int i = 0; i < Q; ++i) { cin >> tp[i] >> x[i] >> y[i]; --x[i]; } int B = 0; while (B * B < Q) ++B; vector ans(N); for (int i = 0; i < B; ++i) { int ql = i * Q / B, qr = (i + 1) * Q / B; vector imos(N + 1); for (int j = ql; j < qr; ++j) { if (tp[j] == "B") { ++imos[x[j]]; --imos[y[j]]; for (int k = ql; k < j; ++k) { if (tp[k] == "A" && x[j] <= x[k] && x[k] < y[j]) { ans[x[k]] += y[k]; } } } } for (int j = 0; j < N; ++j) { imos[j + 1] += imos[j]; ans[j] += A[j] * imos[j]; } for (int j = ql; j < qr; ++j) { if (tp[j] == "A") { A[x[j]] += y[j]; } } } for (int i = 0; i < N; ++i) { if (i) cout << ' '; cout << ans[i]; } return 0; }