/* Goal to be a Master */
#include <algorithm>
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
const int maxN=1e5+1;
pair<int,int> st[4*maxN];
int a[maxN];
void build(int si,int ss,int se)
{
if(ss==se)
{
st[si]=mp(a[ss],1);
return ;
}
else{
int mid=(se+ss)/2;
build(2*si+1,ss,mid);
build(2*si+2,mid+1,se);
st[si].first=min(st[2*si+2].first,st[2*si+1].first);
if(st[2*si+2].first<st[2*si+1].first)
st[si].second=st[2*si+2].second;
else if(st[2*si+2].first>st[2*si+1].first)
st[si].second=st[2*si+1].second;
else
st[si].second=st[2*si+1].second+st[2*si+2].second;
}
}
void update(int si,int ss,int se,int idx,int data)
{
if(se<idx || ss>idx)
return;
if(se==ss)
{
if(ss==idx)
st[si]=mp(data,1);
else
st[si]=mp(a[ss],1);
return;
}
else
{
int mid=(se+ss)/2;
update(2*si+1,ss,mid,idx,data);
update(2*si+2,mid+1,se,idx,data);
st[si].first=min(st[2*si+2].first,st[2*si+1].first);
if(st[2*si+2].first<st[2*si+1].first)
st[si].second=st[2*si+2].second;
else if(st[2*si+2].first>st[2*si+1].first)
st[si].second=st[2*si+1].second;
else
st[si].second=st[2*si+1].second+st[2*si+2].second;
}
}
pair<int,int> query(int si,int ss,int se,int qs,int qe)
{
if(qs>qe)
return {INT_MAX,1};
if(ss==qs && se==qe)
return st[si];
else
{
int mid=(ss+se)/2;
pair<int,int> l=query(2*si+1,ss,mid,qs,min(mid,qe));
pair<int,int> r=query(2*si+2,mid+1,se,max(mid+1,qs),qe);
st[si].first=min(l.first,r.first);
if(l.first<r.first)
st[si].second=l.second;
else if(l.first>r.first)
st[si].second=r.second;
else
st[si].second=l.second+r.second;
return st[si];
}
}
int main()
{
IOS
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>a[i];
build(0,0,n-1);
while(m--)
{
int x;
cin>>x;
if(x==1)
{
int j,k;
cin>>j>>k;
update(0,0,n-1,j,k);
}
else
{
int j,k;
cin>>j>>k;
pair<int,int> h=query(0,0,n-1,j,k-1);
cout<<h.first<<" "<<h.second<<"\n";
}
}
return 0;
}
LyogR29hbCB0byBiZSBhIE1hc3RlciAqLwogICAgICAjaW5jbHVkZSA8YWxnb3JpdGhtPgogICAgICAjaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KICAgICAgI2luY2x1ZGU8c3RyaW5nPgogICAgICB1c2luZyBuYW1lc3BhY2Ugc3RkOwogICAgICAjZGVmaW5lIElPUyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApO2Npbi50aWUoMCk7Y291dC50aWUoMCk7CiAgICAgICNkZWZpbmUgdmkgdmVjdG9yPGludD4KICAgICAgI2RlZmluZSBsbCBsb25nIGxvbmcKICAgICAgI2RlZmluZSBwYiBwdXNoX2JhY2sKICAgICAgI2RlZmluZSBtcCBtYWtlX3BhaXIKICAgICAgI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLHguZW5kKCkKICAgICAgCiBjb25zdCBpbnQgbWF4Tj0xZTUrMTsKIHBhaXI8aW50LGludD4gc3RbNCptYXhOXTsKIGludCBhW21heE5dOwogdm9pZCBidWlsZChpbnQgc2ksaW50IHNzLGludCBzZSkKIHsKICAgICBpZihzcz09c2UpCiAgICAgewogICAgICAgICBzdFtzaV09bXAoYVtzc10sMSk7CiAgICAgICAgIHJldHVybiA7CiAKICAgICB9IAogICAgIGVsc2V7CiAgICAgaW50IG1pZD0oc2Urc3MpLzI7CiAgICAgYnVpbGQoMipzaSsxLHNzLG1pZCk7CiAgICAgYnVpbGQoMipzaSsyLG1pZCsxLHNlKTsKICAgICBzdFtzaV0uZmlyc3Q9bWluKHN0WzIqc2krMl0uZmlyc3Qsc3RbMipzaSsxXS5maXJzdCk7CiAgICAgaWYoc3RbMipzaSsyXS5maXJzdDxzdFsyKnNpKzFdLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPXN0WzIqc2krMl0uc2Vjb25kOwogICAgIGVsc2UgaWYoc3RbMipzaSsyXS5maXJzdD5zdFsyKnNpKzFdLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPXN0WzIqc2krMV0uc2Vjb25kOwogICAgIGVsc2UKICAgICAgc3Rbc2ldLnNlY29uZD1zdFsyKnNpKzFdLnNlY29uZCtzdFsyKnNpKzJdLnNlY29uZDsKICAgICAKICAgICAKICAgICB9CiB9CiB2b2lkIHVwZGF0ZShpbnQgc2ksaW50IHNzLGludCBzZSxpbnQgaWR4LGludCBkYXRhKQogewogICAgIGlmKHNlPGlkeCB8fCBzcz5pZHgpCiAgICAgIHJldHVybjsKICAgICBpZihzZT09c3MpCiAgICAgewogICAgICAgICAKICAgICAgICAgCiAgICAgICAgIGlmKHNzPT1pZHgpCiAgICAgICAgICBzdFtzaV09bXAoZGF0YSwxKTsKICAgICAgICAgZWxzZQogICAgICAgICAgc3Rbc2ldPW1wKGFbc3NdLDEpOyAKICAgICAgICAgcmV0dXJuOwogICAgIH0KICAgICBlbHNlCiAgICAgewogICAgICBpbnQgbWlkPShzZStzcykvMjsKICAgICAgdXBkYXRlKDIqc2krMSxzcyxtaWQsaWR4LGRhdGEpOwogICAgICB1cGRhdGUoMipzaSsyLG1pZCsxLHNlLGlkeCxkYXRhKTsKICAgICBzdFtzaV0uZmlyc3Q9bWluKHN0WzIqc2krMl0uZmlyc3Qsc3RbMipzaSsxXS5maXJzdCk7CiAgICAgaWYoc3RbMipzaSsyXS5maXJzdDxzdFsyKnNpKzFdLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPXN0WzIqc2krMl0uc2Vjb25kOwogICAgIGVsc2UgaWYoc3RbMipzaSsyXS5maXJzdD5zdFsyKnNpKzFdLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPXN0WzIqc2krMV0uc2Vjb25kOwogICAgIGVsc2UKICAgICAgc3Rbc2ldLnNlY29uZD1zdFsyKnNpKzFdLnNlY29uZCtzdFsyKnNpKzJdLnNlY29uZDsKICAgICAgIAogICAgIH0KIH0KcGFpcjxpbnQsaW50PiBxdWVyeShpbnQgc2ksaW50IHNzLGludCBzZSxpbnQgcXMsaW50IHFlKQp7CiAgICBpZihxcz5xZSkKICAgICByZXR1cm4ge0lOVF9NQVgsMX07CiAgICAKICAgIGlmKHNzPT1xcyAmJiBzZT09cWUpCiAgICAgcmV0dXJuIHN0W3NpXTsKICAgIGVsc2UKICAgIHsKICAgICAgICBpbnQgbWlkPShzcytzZSkvMjsKICAgICAgICBwYWlyPGludCxpbnQ+IGw9cXVlcnkoMipzaSsxLHNzLG1pZCxxcyxtaW4obWlkLHFlKSk7CiAgICAgICAgcGFpcjxpbnQsaW50PiByPXF1ZXJ5KDIqc2krMixtaWQrMSxzZSxtYXgobWlkKzEscXMpLHFlKTsKICAgICAgICBzdFtzaV0uZmlyc3Q9bWluKGwuZmlyc3Qsci5maXJzdCk7CiAgICAgaWYobC5maXJzdDxyLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPWwuc2Vjb25kOwogICAgIGVsc2UgaWYobC5maXJzdD5yLmZpcnN0KQogICAgICBzdFtzaV0uc2Vjb25kPXIuc2Vjb25kOwogICAgIGVsc2UKICAgICAgc3Rbc2ldLnNlY29uZD1sLnNlY29uZCtyLnNlY29uZDsKICAgICByZXR1cm4gc3Rbc2ldOwogICAgfQogICAgIAp9CiAgICAgIGludCBtYWluKCkKICAgICAgewogICAgICAgIElPUyAgCiAgICAgICAgaW50IG4sbTsKICAgICAgICBjaW4+Pm4+Pm07CiAgICAgICAgCiAgICAgICAgZm9yKGludCBpPTA7aTxuO2krKykKICAgICAgICAgY2luPj5hW2ldOwogICAgICAgIGJ1aWxkKDAsMCxuLTEpOyAKICAgICAgICB3aGlsZShtLS0pCiAgICAgICAgewogICAgICAgICAgICBpbnQgeDsKICAgICAgICAgICAgY2luPj54OwogICAgICAgICAgICBpZih4PT0xKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgaixrOwogICAgICAgICAgICAgICAgY2luPj5qPj5rOwogICAgICAgICAgICAgICAgdXBkYXRlKDAsMCxuLTEsaixrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGludCBqLGs7CiAgICAgICAgICAgICAgICBjaW4+Pmo+Pms7CiAgICAgICAgICAgICAgICBwYWlyPGludCxpbnQ+IGg9cXVlcnkoMCwwLG4tMSxqLGstMSk7CiAgICAgICAgICAgICAgICBjb3V0PDxoLmZpcnN0PDwiICI8PGguc2Vjb25kPDwiXG4iOwogICAgICAgICAgICB9CiAgICAgICAgfSAKICAgICAgICByZXR1cm4gMDsKICAgICAgfQ==