#include #include #include using namespace atcoder; using mint = modint1000000007; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 int main(){ long long n,m; cin>>n>>m; map> mp; map mp2; rep(i,m){ long long a; scanf("%lld",&a); mp2[i+1] = a; mp[a].insert(i+1); } int q; cin>>q; rep(i,q){ int t; long long x,y; scanf("%d %lld %lld",&t,&x,&y); if(t==1){ if(mp2.count(x)){ mp[mp2[x]].erase(x); if(mp[mp2[x]].size()==0)mp.erase(mp2[x]); mp2[x] += y; mp[mp2[x]].insert(x); } else{ mp2[x] = y; mp[y].insert(x); } } if(t==2){ mp[mp2[x]].erase(x); if(mp[mp2[x]].size()==0)mp.erase(mp2[x]); mp2[x] -= y; mp[mp2[x]].insert(x); } if(t==3){ auto it = mp.end(); it--; auto it2= it->second.end(); it2--; printf("%lld\n",(*it2)); } } return 0; }