import sys input = sys.stdin.readline N_, Q = map(int, input().split()) A = list(map(int, input().split())) Query = [list(map(lambda x: int(x)-1, input().split())) for _ in range(Q)] # 初期化最大値 max_N = (1 << 31) - 1 # 要素数を2の累乗にしておく N = 1 while N < N_: N *= 2 # Segment Tree seg = [[max_N, 0] for _ in range(2*N-1)] # k番目の値(0-indexed)をaに変更 def update(k, a): k += N - 1 seg[k] = [a, k-N+1] while k > 0: k = (k-1)//2 if seg[2*k+1][0] > seg[2*k+2][0]: seg[k] = seg[2*k+2] else: seg[k] = seg[2*k+1] # [l, r)の最小値取得 # kがNodeの番号、対応する区間が[a, b) def query_min(l, r, k=0, a=0, b=N): # 交差してなければmax_N if b <= l or r <= a: return max_N, 0 # 含んでいたらNodeの値 if l <= a and b <= r: return seg[k] # それ以外なら子を見る else: vl = query_min(l, r, k*2+1, a, (a+b)//2) vr = query_min(l, r, k*2+2, (a+b)//2, b) if vl[0] > vr[0]: return vr else: return vl def main(): for i, a in enumerate(A): update(i, a) for com, l, r in Query: if com == 0: al = seg[l+N-1][0] ar = seg[r+N-1][0] update(l, ar) update(r, al) else: print(query_min(l, r+1)[1]+1) if __name__ == "__main__": main()