#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#define N 200010
#define ll long long
using namespace std;
ll a[N];
int n,m;
struct node //线段树
{
int l,r;
ll dat;
}tree[N<<2];
void PushUp(int x) //线段树维护结点信息
{
tree[x].dat=max(tree[x<<1].dat,tree[x<<1|1].dat);
}
void build(int x,int l,int r) //线段树建树
{
tree[x].l=l;
tree[x].r=r;
if (l==r) //叶子节点
{
tree[x].dat=a[l];
return;
}
int mid=(l+r)>>1;
build(x<<1,l,mid);
build(x<<1|1,mid+1,r);
PushUp(x);
}
ll query(int x,int l,int r) //线段树区间查询
{
if (l<=tree[x].l&&r>=tree[x].r)
return abs(tree[x].dat); //找到
int mid=(tree[x].l+tree[x].r)>>1;
ll ans=0;
if (l<=mid) ans=max(ans,query(x<<1,l,r));
if (r>mid) ans=max(ans,query(x<<1|1,l,r));
return ans;
}
void update(int x,int y,ll k) //线段树单点修改
{
if (tree[x].l==tree[x].r)
{
tree[x].dat = k;
return ;
}
int mid=(tree[x].l+tree[x].r)>>1;
if (y<=mid) update(x<<1,y,k);
else update(x<<1|1,y,k);
PushUp(x);
}
int main()
{
while(scanf("%d%d",&n,&m)!=-1)
{
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
build(1,1,n);
char s[10];
while(m--)
{
scanf("%s",&s);
int i,j;
if(s[0]=='U')
{
scanf("%d%d",&i,&j);
update(1,i,j);
}
else if(s[0]=='Q')
{
scanf("%d%d",&i,&j);
printf("%lld\n",query(1,i,j));
}
}
}
return 0;
}