#include <cstdio>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename node_const_iterator, typename node_iterator, typename cmp_fn,
typename _Alloc>
struct tree_max
{
typedef int metadata_type;
tree_max(){}
inline void operator() (node_iterator it, node_const_iterator null) const
{
int mx = (*it)->second;
if (it.get_l_child() != null)
mx = max(mx, it.get_l_child().get_metadata());
if (it.get_r_child() != null)
mx = max(mx, it.get_r_child().get_metadata());
(int&)(it.get_metadata()) = mx;
}
};
typedef tree<int, int, less<int>, splay_tree_tag, tree_max> Tree;
Tree A;
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
int t;
scanf("%d", &t);
A.insert(make_pair(i, t));
}
int m;
scanf("%d", &m);
for (int i = 0; i < m; i++)
{
char t;
int x, y;
scanf(" %c %d %d", &t, &x, &y);
if (t == 'u')
{
A.erase(x);
A.insert(make_pair(x, y));
}
else
{
Tree B, C;
A.split(y, C);
A.split(x - 1, B);
printf("%d ", B.node_begin().get_metadata());
A.join(B);
A.join(C);
}
}
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgp1c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlPHR5cGVuYW1lIG5vZGVfY29uc3RfaXRlcmF0b3IsIHR5cGVuYW1lIG5vZGVfaXRlcmF0b3IsIHR5cGVuYW1lIGNtcF9mbiwKCSAgIHR5cGVuYW1lIF9BbGxvYz4Kc3RydWN0IHRyZWVfbWF4CnsKICAgIHR5cGVkZWYgaW50IG1ldGFkYXRhX3R5cGU7CiAgICAKICAgIHRyZWVfbWF4KCl7fQoKICAgIGlubGluZSB2b2lkIG9wZXJhdG9yKCkgKG5vZGVfaXRlcmF0b3IgaXQsIG5vZGVfY29uc3RfaXRlcmF0b3IgbnVsbCkgY29uc3QKICAgIHsKICAgICAgICBpbnQgbXggPSAoKml0KS0+c2Vjb25kOwogICAgICAgIGlmIChpdC5nZXRfbF9jaGlsZCgpICE9IG51bGwpCiAgICAgICAgICAgIG14ID0gbWF4KG14LCBpdC5nZXRfbF9jaGlsZCgpLmdldF9tZXRhZGF0YSgpKTsKICAgICAgICBpZiAoaXQuZ2V0X3JfY2hpbGQoKSAhPSBudWxsKQogICAgICAgICAgICBteCA9IG1heChteCwgaXQuZ2V0X3JfY2hpbGQoKS5nZXRfbWV0YWRhdGEoKSk7CiAgICAgICAgKGludCYpKGl0LmdldF9tZXRhZGF0YSgpKSA9IG14OwogICAgfQp9OwoKdHlwZWRlZiB0cmVlPGludCwgaW50LCBsZXNzPGludD4sIHNwbGF5X3RyZWVfdGFnLCB0cmVlX21heD4gVHJlZTsKClRyZWUgQTsgCgppbnQgbWFpbigpCnsKICAgIGludCBuOwogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGludCB0OwogICAgICAgIHNjYW5mKCIlZCIsICZ0KTsKICAgICAgICBBLmluc2VydChtYWtlX3BhaXIoaSwgdCkpOwogICAgfQogICAgaW50IG07CiAgICBzY2FuZigiJWQiLCAmbSk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG07IGkrKykKICAgIHsKICAgICAgICBjaGFyIHQ7CiAgICAgICAgaW50IHgsIHk7CiAgICAgICAgc2NhbmYoIiAlYyAlZCAlZCIsICZ0LCAmeCwgJnkpOwogICAgICAgIGlmICh0ID09ICd1JykKICAgICAgICB7CiAgICAgICAgICAgIEEuZXJhc2UoeCk7CiAgICAgICAgICAgIEEuaW5zZXJ0KG1ha2VfcGFpcih4LCB5KSk7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIFRyZWUgQiwgQzsKICAgICAgICAgICAgQS5zcGxpdCh5LCBDKTsKICAgICAgICAgICAgQS5zcGxpdCh4IC0gMSwgQik7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgQi5ub2RlX2JlZ2luKCkuZ2V0X21ldGFkYXRhKCkpOwogICAgICAgICAgICBBLmpvaW4oQik7CiAgICAgICAgICAgIEEuam9pbihDKTsKICAgICAgICB9CiAgICB9Cn0KCg==