//This solution is wrong at 75 test case
#include<bits/stdc++.h>
using namespace std;
#define ll long long
// build tree
ll tree[400001]={0};
void build_tree(ll int *a, ll int s,ll int e, ll int *tree, ll int index)
{
if(s==e)
{
tree[index] = a[s];
return;
}
ll int mid = (s+e)/2;
build_tree(a,s,mid,tree,2*index);
build_tree(a,mid+1,e,tree,2*index+1);
tree[index] = min(tree[2*index],tree[2*index+1]);
return;
}
ll query(ll int *tree,ll int ss,ll int se,ll int qs,ll int qe ,ll int index)
{
//complete overlap
if(ss>=qs and se<=qe)
{
return tree[index];
}
//No Overlap
if(qe<ss || qs>se)
return INT_MAX;
//partial overlap
ll int mid = (ss + se)/2;
ll int left = query(tree,ss,mid,qs,qe,2*index);
ll int right = query(tree,mid+1,se,qs,qe,2*index+1);
return min(left,right);
}
//point update
void point_update(ll int *tree, ll int ss,ll int se, ll int i,ll int inc,ll int index)
{
if(i>se || i<ss)
return;
if(ss == se)
{
tree[index] = inc;
return;
}
ll int mid = (ss + se)/2;
point_update(tree,ss,mid,i,inc,2*index);
point_update(tree,mid+1,se,i,inc,2*index+1);
tree[index] = min(tree[2*index],tree[2*index+1]);
return;
}
ll count_mini(ll int *tree,ll int ss,ll int se,ll int qs,ll int qe ,ll num,ll int index)
{
if(qe<ss || qs>se)
return 0;
if((se<=qe && ss>=qs)&&tree[index]!=num)
return 0;
if((se<=qe || ss>=qs)&&tree[index]>num)
return 0;
if(ss == se )
{
if(tree[index]==num)
return 1;
else
return 0;
}
ll int mid = (ss + se)/2;
ll left = count_mini(tree,ss,mid,qs,qe,num,2*index);
ll right = count_mini(tree,mid+1,se,qs,qe,num,2*index+1);
return left+right;
}
void solve()
{
int n,q;
cin>>n>>q;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
build_tree(a,0,n-1,tree,1);
// for(int i=1;i<=4*n;i++)
// cout<<tree[i]<<endl;
while(q--)
{
ll num,l,r;
cin>>num>>l>>r;
if(num==1)
{
point_update(tree,0,n-1,l,r,1);
}
else
{
ll int num1 = query(tree,0,n-1,l,r-1,1);
ll int num2 = count_mini(tree,0,n-1,l,r-1,num1,1);
cout<<num1<<" "<<num2<<endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int t=1;
// cin>>t;
while(t--)
{
solve();
}
return 0;
}
Ly9UaGlzIHNvbHV0aW9uIGlzIHdyb25nIGF0IDc1IHRlc3QgY2FzZQojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwoKLy8gYnVpbGQgdHJlZQpsbCB0cmVlWzQwMDAwMV09ezB9Owp2b2lkIGJ1aWxkX3RyZWUobGwgaW50ICphLCBsbCBpbnQgcyxsbCBpbnQgZSwgbGwgaW50ICp0cmVlLCBsbCBpbnQgaW5kZXgpCnsKCWlmKHM9PWUpCgl7CgkJdHJlZVtpbmRleF0gPSBhW3NdOwoJCXJldHVybjsKCX0KCWxsIGludCBtaWQgPSAocytlKS8yOwoJYnVpbGRfdHJlZShhLHMsbWlkLHRyZWUsMippbmRleCk7CglidWlsZF90cmVlKGEsbWlkKzEsZSx0cmVlLDIqaW5kZXgrMSk7Cgl0cmVlW2luZGV4XSA9IG1pbih0cmVlWzIqaW5kZXhdLHRyZWVbMippbmRleCsxXSk7CglyZXR1cm47Cn0KbGwgcXVlcnkobGwgaW50ICp0cmVlLGxsIGludCBzcyxsbCBpbnQgc2UsbGwgaW50IHFzLGxsIGludCBxZSAsbGwgaW50IGluZGV4KQp7CgkvL2NvbXBsZXRlIG92ZXJsYXAKCWlmKHNzPj1xcyBhbmQgc2U8PXFlKQoJewoJCXJldHVybiB0cmVlW2luZGV4XTsKCX0KCS8vTm8gT3ZlcmxhcAoJaWYocWU8c3MgfHwgcXM+c2UpCglyZXR1cm4gSU5UX01BWDsKCgkvL3BhcnRpYWwgb3ZlcmxhcAoJbGwgaW50IG1pZCA9IChzcyArIHNlKS8yOwoJbGwgaW50IGxlZ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