import sys def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 a = list(map(int, input[ptr:ptr+M])) ptr += M Q = int(input[ptr]) ptr += 1 queries = [] for _ in range(Q): T = int(input[ptr]) X = int(input[ptr+1]) Y = int(input[ptr+2]) queries.append((T, X, Y)) ptr += 3 # Determine the size of the segment tree as the next power of two >= M size = 1 while size < M: size *= 2 # Initialize the segment tree tree = [(0, 0)] * (2 * size) for x in range(1, M + 1): tree[size + x - 1] = (a[x - 1], x) for x in range(M + 1, size + 1): tree[size + x - 1] = (0, x) # Build the internal nodes for i in range(size - 1, 0, -1): tree[i] = max(tree[2 * i], tree[2 * i + 1]) output = [] for t, x, y in queries: if t == 1 or t == 2: pos = size + x - 1 current_count, current_x = tree[pos] if t == 1: new_count = current_count + y else: new_count = current_count - y tree[pos] = (new_count, x) pos //= 2 while pos >= 1: left = 2 * pos right = 2 * pos + 1 tree[pos] = max(tree[left], tree[right]) pos //= 2 else: output.append(str(tree[1][1])) print('\n'.join(output)) if __name__ == '__main__': main()