#include<bits/stdc++.h>
using namespace std;
void build_segment_tree(int *arr, int *a, int node, int start, int end)
{
if(start == end)
{
arr[node] = a[start];
return;
}
int mid = (start+end) / 2;
build_segment_tree(arr, a, 2*node+1, start, mid);
build_segment_tree(arr, a, 2*node+2, mid+1, end);
arr[node] = min(arr[2*node+1], arr[2*node+2]);
}
void update_segment_tree(int *arr, int *a, int node, int start, int end, int idx, int new_value)
{
if(start == end)
{
a[idx] = new_value;
arr[node] = new_value;
return;
}
int mid = (start+end)/2;
if(start <= idx && idx <= end)
{
update_segment_tree(arr, a, 2*node+1, start, mid, idx, new_value);
}
else
{
update_segment_tree(arr, a, 2*node+2, mid+1, end, idx, new_value);
}
arr[node] = min(arr[2*node+1], arr[2*node+2]);
}
int query(int *arr, int *a, int node, int start, int end, int l, int r)
{
if(r < start || end < l)
return INT_MAX;
if(l <= start && end <= r)
{
return arr[node];
}
int mid = (start+end)/2;
int p1 = query(arr, a, 2*node+1, start, mid, l, r);
int p2 = query(arr, a, 2*node+2, mid+1, end, l, r);
return min(p1, p2);
}
int main()
{
int n, q;
cin >> n >> q;
int a[n];
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
int arr[3*n];
memset(arr, INT_MAX, sizeof(a));
build_segment_tree(arr, a, 0, 0, n-1);
char temp;
int l, r;
while(q--)
{
cin >> temp >> l >> r;
if(temp == 'q')
{
l--, r--;
cout << query(arr, a, 0, 0, n-1, l, r) << '\n';
}
else
{
l--;
update_segment_tree(arr, a, 0, 0, n-1, l, r);
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdm9pZCBidWlsZF9zZWdtZW50X3RyZWUoaW50ICphcnIsIGludCAqYSwgaW50IG5vZGUsIGludCBzdGFydCwgaW50IGVuZCkKewoJaWYoc3RhcnQgPT0gZW5kKQoJewoJCWFycltub2RlXSA9IGFbc3RhcnRdOwoJCXJldHVybjsKCX0KCWludCBtaWQgPSAoc3Rhcn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