#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int A[200005];
//int max;
//int min;
struct node
{
int left;
int right;
int max; //维护最大值
int sum; //维护区间和
int min; //维护最小值
}Tree[200000*4];
int num[200005];
void maintain(int root) //向上调整
{
int LC = root<<1;
int RC = (root<<1)+1;
Tree[root].sum = Tree[LC].sum + Tree[RC].sum;
Tree[root].max = max(Tree[LC].max,Tree[RC].max);
Tree[root].min = min(Tree[LC].min,Tree[RC].min);
}
void Build(int root,int start,int end) //构建线段树
{
Tree[root].left = start;
Tree[root].right = end;
if(start == end)
{
Tree[root].max =0;
return;
}
int mid = (start + end)>>1;
Build(root<<1,start,mid);
Build((root<<1)+1,mid+1,end);
maintain(root);
}
void insert(int root,int pos,int value) //更新点的值
{
if(Tree[root].left == Tree[root].right && Tree[root].left == pos)
{
Tree[root].max = value;
return;
}
int mid = (Tree[root].left + Tree[root].right)>>1;
if(pos <= mid)
insert(root<<1,pos,value);
else
insert((root<<1)+1,pos,value);
maintain(root);
}
int RmaxQ(int root,int start,int end) //查询区间最大值
{
if(start == Tree[root].left && Tree[root].right == end)
{
return Tree[root].max;
}
int mid = (Tree[root].left + Tree[root].right)>>1;
int ret = 0; //modify this
if(end <= mid)
ret = max(ret,RmaxQ(root<<1,start,end));
else if(start >= mid+1)
ret = max(ret,RmaxQ((root<<1)+1,start,end));
else
{
int a = RmaxQ(root<<1,start,mid);
int b = RmaxQ((root<<1)+1,mid+1,end);
ret = max(a,b);
}
return ret;
}
int main()
{
int n,m,i,j;
int st,po,va,en,ans,xx;
char sa[10];
while(scanf("%d%d",&n,&m)!=EOF)
{
Build(1,1,n);
for(i=1;i<=n;i++)
{
scanf("%d",&num[i]);
insert(1,i,num[i]);
}
for(i=0;i<m;i++)
{
scanf("%s",sa);
if(sa[0]=='U')
{
scanf("%d%d",&po,&va);
insert(1,po,va);
}
else
{
scanf("%d%d",&st,&en);
ans=RmaxQ(1,st,en);
printf("%d\n",ans);
}
}
}
}