// code of JUYU ^ ^ never doubt youself !
#include <bits/stdc++.h>
typedef long long ll;
#define int ll
#define For(i,a,b) for (int i = a; i <= b; i ++)
#define Dow(i,a,b) for (int i = b; i >= a; -- i)
#define ms(a,b) memset(a, b, sizeof (a))
#define fir first
#define sec second
#define mk make_pair
#define pb push_back
#define eb emplace_back
using namespace std;
typedef pair<int,int> PII;
const int mod = 998244353;
const int MOD = 1000000007;
const int maxn = 2e5 + 5;
inline ll read()
{
ll t = 0, dp = 1; char c = getchar();
while(!isdigit(c)) {if (c == '-') dp = -1; c = getchar();}
while(isdigit(c)) t = t * 10 + c - 48, c = getchar();
return t * dp;
}
inline void write(ll x){if (x < 0){putchar('-'); x = -x;} if(x >= 10) write(x / 10); putchar(x % 10 + 48);}
inline void writeln(ll x){write(x); puts("");}
inline void write_p(ll x){write(x); putchar(' ');}
inline void write_b(ll x){putchar(' '); write(x);}
inline int qpow(int x, int y, int z){int ret = 1; for (; y; y /= 2, x = x * x % z) if (y & 1) ret = ret * x % z; return ret;}
inline int PrimeInv(int x, int y, int z){return qpow(x, y - 2, z);}
PII sum[maxn * 4];
int a[maxn];
inline PII
inline void update(int x)
{
if (sum[x * 2].fir == sum[x * 2 + 1].fir) sum[x] = {sum[x * 2].fir, sum[x * 2].sec + sum[x * 2 + 1].sec};
else sum[x] = min(sum[x * 2], sum[x * 2 + 1]);
}
inline void build(int x, int l, int r)
{
if (l == r)
{
sum[x] = {a[l], 1};
return ;
}
int mid = (l + r) / 2;
build(x * 2, l, mid);
build(x * 2 + 1, mid + 1, r);
update(x);
}
inline PII query(int x, int l, int r, int ql, int qr)
{
if (ql <= l && qr >= r) return sum[x];
int mid = (l + r) / 2;
PII lret = {INT_MAX, 0}, rret = {INT_MAX, 0};
if (ql <= mid) lret = query(x * 2, l, mid, ql, qr);
if (qr > mid) rret = query(x * 2 + 1, mid + 1, r, ql, qr);
update(x);
return merge(lret, rret);
}
inline void change(int x, int l, int r, int v, int k)
{
if (l == v && r == v)
{
sum[x] = {k, 1};
return ;
}
int mid = (l + r) / 2;
if (v <= mid) change(x * 2, l, mid, v, k);
else change(x * 2 + 1, mid + 1, r, v, k);
update(x);
}
signed main()
{
int n = read(), m = read();
For(i,1,n) a[i] = read();
build(1, 1, n);
while (m --)
{
int op = read();
if (op == 1)
{
int v = read(), k = read();
change(1, 1, n, v + 1, k);
}
else
{
int l = read(), r = read();
PII ans = query(1, 1, n, l + 1, r);
write_p(ans.fir); writeln(ans.sec);
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
struct item
{
int m, c;
};
struct segtree
{
int size;
vector<item> sums;
item NEUTRUAL_ELEMENT = {INT_MAX, 0};
item merge(item a, item b)
{
if (a.m < b.m) return a;
if (a.m > b.m) return b;
return {a.m, a.c + b.c};
}
item single(int x)
{
return {x, 1};
}
void init(int n)
{
size = 1;
while (size < n) size *= 2;
sums.resize(2 * size);
}
void build(vector<int> &a, int x, int lx, int rx)
{
if (rx - lx == 1)
{
if (lx < (int)a.size()) sums[x] = single(a[lx]);
return ;
}
int m = (lx + rx) / 2;
build(a, x * 2 + 1, lx, m);
build(a, x * 2 + 2, m, rx);
sums[x] = merge(sums[x * 2 + 2], sums[x * 2 + 1]);
}
void build(vector<int> &a)
{
build(a, 0, 0, size);
}
void set(int i, int v, int x, int lx, int rx)
{
if (rx - lx == 1)
{
sums[x] = single(v);
return ;
}
int m = (lx + rx) / 2;
if (i < m) set(i, v, x * 2 + 1, lx, m);
else set(i, v, x * 2 + 2, m, rx);
sums[x] = merge(sums[x * 2 + 2], sums[x * 2 + 1]);
}
void set(int i, int v)
{
set(i, v, 0, 0, size);
}
item sum(int l, int r, int x, int lx, int rx)
{
if (lx >= r || l >= rx) return NEUTRUAL_ELEMENT;
if (lx >= l && r >= rx) return sums[x];
int m = (lx + rx) / 2;
item s1 = sum(l, r, x * 2 + 1, lx, m);
item s2 = sum(l, r, x * 2 + 2, m, rx);
return merge(s1, s2);
}
item sum(int l, int r)
{
return sum(l, r, 0, 0, size);
}
};
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
segtree st;
st.init(n);
vector<int> a(n);
for (int i = 0; i < n; i ++)
{
cin >> a[i];
}
st.build(a);
while (m --)
{
int op; cin >> op;
if (op == 1)
{
int i, v; cin >> i >> v;
st.set(i, v);
}
else
{
int l, r; cin >> l >> r;
item res = st.sum(l, r);
cout << res.m << " " << res.c << "\n";
}
}
return 0;
}