#include <iostream> #include <vector> #include <algorithm> int main() { int N, M; while(std::cin>>N>>M) { std::vector<int> v_data; v_data.clear(); for(size_t i=0;i<N;++i) { int data_in; std::cin>>data_in; v_data.push_back(data_in); } for(size_t i=0;i<M;++i){ char in; int a, b; std::cin>>in>>a>>b; if(in == 'U'){ v_data.at(a-1)=b; } if(in == 'Q'){ if(a == b) { std::cout<<v_data.at(a-1)<<std::endl; } if(a > b) { std::cout<<*max_element(v_data.begin()+b-1, v_data.begin()+a)<<std::endl; } if(a < b) { std::cout<<*max_element(v_data.begin()+a-1, v_data.begin()+b)<<std::endl; } } } } return 0; }