#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef array<int, 3> ai3;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int Mod = 1e9 + 7;
inline void uadd(int &a, int b){ a += b-Mod; a += (a>>31) & Mod; }
inline void usub(int &a, int b){ a -= b, a += (a>>31) & Mod; }
inline void umul(int &a, int b){ a = (int)(1ll * a * b % Mod); }
inline int add(int a, int b){ a += b-Mod; a += (a>>31) & Mod; return a; }
inline int sub(int a, int b){ a -= b, a += (a>>31) & Mod; return a; }
inline int mul(int a, int b){ a = (int)(1ll * a * b % Mod); return a; }
int qpow(int b, ll p){ int ret = 1; while(p){ if(p&1) umul(ret, b); umul(b, b), p >>= 1; } return ret; }
const int fN = 10010;
int fact[fN], invfact[fN], pw2[fN], invpw2[fN], inv[fN];
void initfact(int n){
pw2[0] = 1; for(int i = 1; i <= n; ++i) pw2[i] = mul(pw2[i-1], 2);
invpw2[0] = 1; for(int i = 1; i <= n; ++i) invpw2[i] = mul(invpw2[i-1], (Mod+1) / 2);
fact[0] = 1; for(int i = 1; i <= n; ++i) fact[i] = mul(fact[i-1], i);
invfact[n] = qpow(fact[n], Mod-2); for(int i = n; i > 0; --i) invfact[i-1] = mul(invfact[i], i);
for(int i = 1; i <= n; ++i) inv[i] = mul(invfact[i], fact[i-1]);
}
int binom(int n, int m){ return (m < 0 || m > n) ? 0 : mul(fact[n], mul(invfact[m], invfact[n-m])); }
const double pi = acos(-1);
template<typename T> inline void chmax(T &_a, T _b){ (_a<_b) ? (_a=_b) : 0; }
template<typename T> inline void chmin(T &_a, T _b){ (_b<_a) ? (_a=_b) : 0; }
mt19937_64 rng(58);
inline int myrand(int l, int r){ return (int)(rng() % (r-l+1)) + l; }
int n, q, a[500500];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
rep(i, n) cin >> a[i];
while(q--){
int tp;
cin >> tp;
if(tp == 1){
int x, y;
cin >> x >> y;
--x;
a[x] = y;
} else {
int l;
cin >> l;
--l;
int mn0 = inf, mn1 = inf, mn2 = inf, ans = -1;
for(int i = l; i < n; ++i){
chmin(mn0, a[i]);
if(mn0 < a[i]) chmin(mn1, a[i]);
if(mn1 < a[i]) chmin(mn2, a[i]);
if(mn2 < a[i]){ ans = i+1; break; }
}
cout << ans << "\n";
}
}
return 0;
}