import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); long n = Long.parseLong(sa[0]); int m = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); long[] a = new long[m]; for (int i = 0; i < m; i++) { a[i] = Long.parseLong(sa[i]); } int q = Integer.parseInt(br.readLine()); int[] t = new int[q]; int[] x = new int[q]; long[] y = new long[q]; for (int i = 0; i < q; i++) { sa = br.readLine().split(" "); t[i] = Integer.parseInt(sa[0]); x[i] = Integer.parseInt(sa[1]); y[i] = Long.parseLong(sa[2]); } br.close(); TreeMap> map = new TreeMap<>(); Map map2 = new HashMap<>(); for (int i = 0; i < m; i++) { TreeSet set = map.get(a[i]); if (set == null) { set = new TreeSet<>(); map.put(a[i], set); } set.add(i + 1); map2.put(i + 1, a[i]); } PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < q; i++) { if (t[i] == 3) { pw.println(map.lastEntry().getValue().last()); } else { long bef = map2.get(x[i]); long aft = bef; if (t[i] == 1) { aft += y[i]; } else { aft -= y[i]; } TreeSet set1 = map.get(bef); TreeSet set2 = map.get(aft); if (set2 == null) { set2 = new TreeSet<>(); map.put(aft, set2); } set1.remove(x[i]); set2.add(x[i]); if (set1.isEmpty()) { map.remove(bef); } map2.put(x[i], aft); } } pw.flush(); } }