#include <bits/stdc++.h>
using namespace std;
struct aint {
int val;
int st;
int dr;
aint* left;
aint* right;
};
aint emptyaint {
-1,
0,
0,
NULL,
NULL,
};
aint* makesons( aint* root ) {
int st = root->st;
int dr = root->dr;
int mij = ( st + dr ) / 2;
if ( root->left == NULL ) {
root->left = new aint {
-1,
st,
mij,
NULL,
NULL,
};
}
if ( root->right == NULL ) {
root->right = new aint {
-1,
mij + 1,
dr,
NULL,
NULL,
};
}
return root;
}
aint* update( aint* root, int poz, int val ) {
root = makesons( root );
int st = root->st, dr = root->dr, mij = ( st + dr ) / 2;
if ( st == dr )
root->val = val;
else {
if ( poz <= mij )
root->left = update( root->left, poz, val );
else
root->right = update( root->right, poz, val );
root->val = max( root->left->val, root->right->val );
}
return root;
}
int query( aint* root, int a, int b ) {
root = makesons( root );
int st = root->st, dr = root->dr, mij = ( st + dr ) / 2;
if ( a == st && b == dr )
return root->val;
if ( b <= mij )
return query( root->left, a, b );
if ( a > mij )
return query( root->right, a, b );
int x = query( root->left, a, mij );
int y = query( root->right, mij + 1, b );
return max( x, y );
}
int main() {
ifstream fin( "arbint.in" );
ofstream fout( "arbint.out" );
int n, q, i;
fin >> n >> q;
aint* root = new aint {
-1,
0,
n - 1,
NULL,
NULL,
};
for ( i = 0; i < n; i ++ ) {
int a;
fin >> a;
root = update( root, i, a );
}
for ( i = 0; i < q; i ++ ) {
int tip, a, b;
fin >> tip >> a >> b;
if ( tip == 1 ) {
root = update( root, a - 1, b );
} else {
fout << query( root, a - 1, b - 1 ) << '\n';
}
}
return 0;
}