import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextLong() val m = nextInt() val a = Array(m) { nextLong() } val b = Array(m) { 0L to 0 } for (i in 0 until m) { b[i] = a[i] to i } val seg = SegTree(b, { x, y -> if (x.first > y.first) x else y }, 0L to 0) val q = nextInt() for (_i in 0 until q) { val t = nextInt() val x = nextInt() - 1 val y = nextLong() if (t == 1) { seg[x] = seg[x].first + y to seg[x].second } else if (t == 2) { seg[x] = seg[x].first - y to seg[x].second } else { println(seg.allProd().second + 1) } } } class SegTree(private val n: Int, private val op: (Monoid, Monoid) -> Monoid, private val e: Monoid) { private var d: MutableList private var size = 1 private var log = 0 init { while (size < n) { size *= 2 log++ } d = MutableList(2 * size) { e } } constructor(a: Array, op: (Monoid, Monoid) -> Monoid, e: Monoid) : this(a.count(), op, e) { for (i in 0 until n) { d[size + i] = a[i] } for (i in size - 1 downTo 1) update(i) } operator fun set(p: Int, x: Monoid) { if (p !in 0 until n) { throw IllegalArgumentException() } val p1 = p + size d[p1] = x for (i in 1..log) { update(p1 shr i) } } operator fun get(p: Int): Monoid { if (p !in 0 until n) { throw IllegalArgumentException() } return d[p + size] } fun prod(range: IntRange): Monoid { val l = range.first val r = range.last + 1 if (l !in 0..r || r > n) { throw IllegalArgumentException() } var sml = e var smr = e var l1 = l + size var r1 = r + size while (l1 < r1) { if (l1 and 1 != 0) sml = op(sml, d[l1++]) if (r1 and 1 != 0) smr = op(d[--r1], smr) l1 /= 2 r1 /= 2 } return op(sml, smr) } fun allProd(): Monoid { return d[1] } fun maxRight(l: Int, f: (Monoid) -> Boolean): Int { if (l !in 0..n || !f(e)) { throw IllegalArgumentException() } if (l == n) return n var l1 = l + size var sm = e do { while (l1 % 2 == 0) l1 /= 2 if (!f(op(sm, d[l1]))) { while (l1 < size) { l1 *= 2 if (f(op(sm, d[l1]))) { sm = op(sm, d[l1]) l1++ } } return l1 - size } sm = op(sm, d[l1]) l1++ } while ((l1 and -l1) != l1) return n } fun minLeft(r: Int, f: (Monoid) -> Boolean): Int { if (r !in 0..n || !f(e)) { throw IllegalArgumentException() } if (r == 0) return 0 var r1 = r + size var sm = e do { r1-- while (r1 > 1 && r1 % 2 != 0) r1 /= 2 if (!f(op(d[r1], sm))) { while (r1 < size) { r1 = 2 * r1 + 1 if (f(op(d[r1], sm))) { sm = op(d[r1], sm) r1-- } } return r1 + 1 - size } sm = op(d[r1], sm) } while ((r1 and -r1) != r1) return 0 } private fun update(k: Int) { d[k] = op(d[2 * k], d[2 * k + 1]) } fun joinToString(s: String = ", "): String { return (0 until n).map { this[it] }.joinToString(s) } } fun main() { Thread(null, { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() }, "solve", 1.shl(26)) .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } } .apply { start() }.join() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion