import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min val MOD = 1_000_000_007 class RangeUpdateTree(n: Int, private val zero: Long, private val f: (Long, Long) -> Long) { private val N = if (Integer.highestOneBit(n) == n) n else Integer.highestOneBit(n) shl 1 private val dat = LongArray(2 * N){zero} /** * [l, r) */ fun add(l: Int, r: Int, a: Long) { var left = l + N var right = r - 1 + N while(left <= right) { if ((left and 1) == 1) dat[left] = f(dat[left], a) if ((right and 1) == 0) dat[right] = f(dat[right], a) left = (left + 1) shr 1 // 右の子供なら右の親に移動 right = (right - 1) shr 1 // 左の子供なら左の親に移動 } } fun query(i: Int): Long { var ix = N + i var res: Long = zero while(ix >= 1) { res = f(res, dat[ix]) ix = ix shr 1 } return res } } data class Query(val isA: Boolean, val x: Int, val y: Int) class Solver(stream: InputStream, private val out: java.io.PrintWriter) { fun solve() { val N = ni() val Q = ni() val A = na(N) val queries = Array(Q) { Query(ns() == "A", ni(), ni()) } val ans = LongArray(N) val tree = RangeUpdateTree(N, 0, Long::plus) for (i in Q -1 downTo 0) { if (queries[i].isA) { val ix = queries[i].x - 1 val v = queries[i].y val times = tree.query(ix) ans[ix] += times * v } else { val s = queries[i].x - 1 val t = queries[i].y tree.add(s, t, 1) } } for (i in 0 until N) { val times = tree.query(i) ans[i] += times * A[i] } out.println(ans.joinToString(" ")) } private val isDebug = try { // なんか本番でエラーでる System.getenv("MY_DEBUG") != null } catch (t: Throwable) { false } private var tokenizer: StringTokenizer? = null private val reader = BufferedReader(InputStreamReader(stream), 32768) private fun next(): String { while (tokenizer == null || !tokenizer!!.hasMoreTokens()) { tokenizer = StringTokenizer(reader.readLine()) } return tokenizer!!.nextToken() } private fun ni() = next().toInt() private fun nl() = next().toLong() private fun ns() = next() private fun na(n: Int, offset: Int = 0): IntArray { return map(n) { ni() + offset } } private fun nal(n: Int, offset: Int = 0): LongArray { val res = LongArray(n) for (i in 0 until n) { res[i] = nl() } return res } private inline fun map(n: Int, f: (Int) -> Int): IntArray { val res = IntArray(n) for (i in 0 until n) { res[i] = f(i) } return res } private inline fun debug(msg: () -> String) { if (isDebug) System.err.println(msg()) } private fun debug(a: LongArray) { debug { a.joinToString(" ") } } private fun debug(a: IntArray) { debug { a.joinToString(" ") } } private fun debug(a: BooleanArray) { debug { a.map { if (it) 1 else 0 }.joinToString("") } } private fun debugDim(A: Array) { if (isDebug) { for (a in A) { debug(a) } } } /** * 勝手にimport消されるのを防ぎたい */ private fun hoge() { min(1, 2) max(1, 2) abs(-10) } } fun main() { val out = java.io.PrintWriter(System.out) Solver(System.`in`, out).solve() out.flush() }