#include <bits/stdc++.h>
///https://cp-algorithms.com/data_structures/segment_tree.html
///https://www.infoarena.ro/tori-de-intervale
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n,m;
int t[400002];
int v[100002];
void build(int root, int st, int dr){
if(st==dr){
t[root] = v[st];
return;
}
int m = (st + dr) / 2;
build(root * 2, st, m); /// construim subarborele stang
build(root * 2 + 1, m + 1, dr); /// construim subarborele drept
t[root] = max(t[root * 2], t[root * 2 + 1]);
}
int vmax(int poz, int a, int b, int st, int dr){
if(st >= a && b >= dr)
return t[poz];
int m = (st + dr) / 2, r1 = 0, r2 = 0;
if(a <= m)
r1 = vmax(2 * poz, a, b, st, m); /// merg in subarborele stang
if(b > m)
r2 = vmax(2 * poz + 1, a, b, m + 1, dr); /// merg in subarborele drept
return max(r1, r2);
}
void update(int root, int a, int b, int st, int dr){
if(st == dr){
t[root] = b;
return;
}
int m = (st + dr) / 2;
if(a <= m)
update(root * 2, a, b, st, m);
else
update(root * 2 + 1, a, b, m + 1, dr);
t[root] = max(t[root * 2],
t[root * 2 + 1]);
}
void read(){
fin>>n>>m;
for(int i = 1; i <= n; i ++)
fin>>v[i];
build(1, 1, n);
for(int i = 1; i <= 4*n; i ++)
cout<<t[i]<<" ";
}
void solve(){
int task, a, b;
for(int i = 1; i <= m; i ++){
fin>>task>>a>>b;
if(task == 1) update(1, a, b, 1, n);
else fout<<vmax(1, a, b, 1, n)<<"\n";
}
cout<<"\n";
for(int i = 1; i <= 4*n; i ++)
cout<<t[i]<<" ";
fin.close();
fout.close();
}
int main()
{
read();
solve();
return 0;
}