import sys input = sys.stdin.readline n, q = map(int, input().split()) A = list(map(int, input().split())) def segfunc(x, y): if x[0] <= y[0]: return x else: return y def init(init_val): # set_val for i in range(n): seg[i+num-1] = [init_val[i], i] # built for i in range(num-2, -1, -1): seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) def update(l, r): al = seg[l+num-1][0] ar = seg[r+num-1][0] k = l + num - 1 seg[k][0] = ar while k: k = (k-1)//2 seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) k = r + num - 1 seg[k][0] = al while k: k = (k-1)//2 seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) def query(p, q): if q <= p: return ide_ele p += num - 1 q += num - 2 res = [ide_ele, n] while q-p>1: if p&1 == 0: res = segfunc(res, seg[p]) if q&1 == 1: res = segfunc(res, seg[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = segfunc(res, seg[p]) else: res = segfunc(segfunc(res, seg[p]), seg[q]) return res # identity element ide_ele = n+1 # num: n以上の最小の2のべき乗 num = 2**(n-1).bit_length() seg = [[ide_ele, n] for _ in range(2*num)] init(A) #print(seg) for _ in range(q): c, l, r = map(int, input().split()) l, r = l-1, r-1 if c == 1: update(r, l) else: res = query(l, r+1) print(res[1]+1)