import java.util.List; import java.util.ArrayList; import java.util.Scanner; public class No1705 { private static class KeyValue implements Comparable { public Integer key; public Long value; KeyValue(int key, long value) { this.key = key; this.value = value; } public int compareTo(KeyValue kv) { int n = value.compareTo(kv.value); if (n == 0) { return key.compareTo(kv.key); } else { return n; } } public KeyValue max(KeyValue kv) { return this.compareTo(kv) >= 0 ? this : kv; } } private static class SegmentTree { private int n; private KeyValue[] dat; SegmentTree(int n) { this.n = 1; while (this.n < n) { this.n *= 2; } dat = new KeyValue[2*this.n-1]; for (int i=0; i < this.n*2-1; i++) { dat[i] = new KeyValue(-1, -1L); } } public void update(int k, long a) { KeyValue kv = new KeyValue(k, a); k += n - 1; dat[k] = kv; while (k > 0) { k = (k - 1) / 2; dat[k] = dat[k * 2 + 1].max(dat[k * 2 + 2]); } } public int max() { return dat[0].key + 1; } public long dat(int i) { return dat[i + n - 1].value; } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); long N = scan.nextLong(); int M = scan.nextInt(); SegmentTree tree = new SegmentTree(M); for (int i=0; i < M; i++) { long a = scan.nextLong(); tree.update(i, a); } int Q = scan.nextInt(); for (int i=0; i < Q; i++) { int t = scan.nextInt(); int x = scan.nextInt(); long y = scan.nextLong(); if (t == 1) { tree.update(x-1, tree.dat(x-1) + y); } else if (t == 2) { tree.update(x-1, tree.dat(x-1) - y); } else { System.out.println(tree.max()); } } scan.close(); } }