from collections import Counter
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
Q=int(input())

H=[]
C=Counter()

for i in range(M):
    a=A[i]
    C[i+1]=a
    H.append((-a,-(i+1)))

heapq.heapify(H)

#print(H)

for queries in range(Q):
    t,x,y=map(int,input().split())

    if t==1:
        C[x]+=y
        heapq.heappush(H,(-C[x],-x))
    elif t==2:
        C[x]-=y
        heapq.heappush(H,(-C[x],-x))
    else:
        while True:
            z,w=H[0]

            if C[-w]!=-z:
                heapq.heappop(H)
            else:
                break

        print(-H[0][1])