#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int n2=1;
	while(n2<n){
		n2*=2;
	}
	vector<pair<int, int>> v(2*n2);
	for(int i=n2+n; i<2*n2; i++){
		v[i].first=0;
		v[i].second=INT_MAX;
	}
	for(int i=n2; i<n2+n; i++){
		cin >> v[i].first;
		v[i].second=i;
	}
	for(int i=n2-1; i>0; i--){
		v[i].first=max(v[2*i].first, v[2*i+1].first);
		if(v[2*i].first>v[2*i+1].first){
			v[i].second = v[2*i].second;
		}
		else if(v[2*i].first<v[2*i+1].first){
			v[i].second = v[2*i+1].second;
		}
		else{
			v[i].second = min(v[2*i].first, v[2*i+1].first);
		}
	}
	for(int i=0; i<m; i++){
		string x;
		cin >> x;
		if(x=="PIORUN"){
			int a, b, c;
			cin >> a >> b >> c;
			a=a+n2-1;
			b=b+n2-1;
			int d=INT_MIN, e=INT_MAX;
			while(a<=b){
				if(a%2==1){
					if(v[a].first>d || (v[a].first==d && e>v[a].second)){
						e=v[a].second;
						d=v[a].first;
					}
					a++;
				}
				if(b%2==0){
					if(v[b].first>d || (v[b].first==d && e>v[b].second)){
						e=v[b].second;
						d=v[b].first;
					}
					b--;
				}
				a/=2;
				b/=2;
			}
			int p=e;
			v[p].first=max(v[p].first-c, 0);
			cout << p-n2+1 << " " << v[p].first << endl;
			v[p].second=p;
			while(p>0){
				v[p].first=max(v[2*p].first, v[2*p+1].first);
				if(v[2*p].first>v[2*p+1].first){
					v[p].second = v[2*p].second;
				}
				else if(v[2*p].first<v[2*p+1].first){
					v[p].second = v[2*p+1].second;
				}
				else{
					v[p].second = min(v[2*p].first, v[2*p+1].first);
				}
				p/=2;
			}
		}
		else if(x=="WZROST"){
			int a, b;
			cin >> a >> b;
			a=a+n2-1;
			int p=a/2;
			v[a].first+=b;
			while(p>0){
				v[p].first=max(v[2*p].first, v[2*p+1].first);
				if(v[2*p].first>v[2*p+1].first){
					v[p].second = v[2*p].second;
				}
				else if(v[2*p].first<v[2*p+1].first){
					v[p].second = v[2*p+1].second;
				}
				else{
					v[p].second = min(v[2*p].first, v[2*p+1].first);
				}
				p/=2;
			}
			cout << v[a].first << endl;
		}
	}
	return 0;
}