#include <bits/stdc++.h>
class InParser{private:FILE *fin;char *buff;short pos=4095;inline char get_ch(){++pos;if(pos==4096){pos=0;fread(buff,1,4096,fin);}return buff[pos];}public:InParser(const char *file){fin=fopen(file, "r");buff=new char[4096]();}InParser& operator>>(int &x){char ch=get_ch();while(!isdigit(ch))ch=get_ch();x=ch-'0';ch=get_ch();while(isdigit(ch)){x=x*10+ch-'0';ch=get_ch();}return *this;}};class OutParser{private:FILE *fout;char *buff;short pos=0;inline void write_ch(char ch){if(pos==4096){pos=0;fwrite(buff,1,4096,fout);}buff[pos]=ch;++pos;}public:OutParser(const char *file){fout=fopen(file,"w");buff=new char[4096]();}~OutParser(){fwrite(buff,1,pos,fout);fclose(fout);}OutParser& operator<<(int x){if(x<10)write_ch(x+'0');else{(*this)<<(x/10);write_ch(x%10+'0');}return *this;}OutParser& operator<<(char ch){write_ch(ch);return *this;}};int n,queries,aint[400000],v[100000],i,left,right,update_pos,val,x,y,op;inline void build(int node,int nleft,int nright){if(nleft==nright)aint[node]=v[nleft];else{int mid=(nleft+nright)>>1;build(node<<1,nleft,mid);build((node<<1)+1,mid+1,nright);aint[node]=std::max(aint[node<<1],aint[(node<<1)+1]);}}inline int query(int node,int nleft,int nright){if(left>nright or right<nleft)return -1;if(left<=nleft and right>=nright)return aint[node];int mid=(nleft+nright)>>1;return std::max(query(node<<1,nleft,mid),query((node<<1)+1,mid+1,nright));}inline void update(int node,int nleft,int nright){if(nleft==nright)aint[node]=val;else{int mid=(nleft+nright)>>1;if(update_pos<=mid)update(node<<1,nleft,mid);else update((node<<1)+1,mid+1,nright);aint[node]=std::max(aint[node<<1],aint[(node<<1)+1]);}}int main(){InParser fin("arbint.in");fin>>n>>queries;for(i=1;i<=n;++i)fin>>v[i];build(1,1,n);OutParser fout("arbint.out");while(queries){--queries;fin>>op>>x>>y;if(op){update_pos=x;val=y;update(1,1,n);}else{left=x;right=y;fout<<query(1,1,n)<<'\n';}}return 0;}