n, q = map(int, input().split()) A = list(map(int, input().split())) infi = 10 ** 20 def func(pair1, pair2): idx1, val1 = pair1 idx2, val2 = pair2 if val1 < val2: res = pair1 else: res = pair2 return res class SegmentTree: # 1-index def __init__(self, A: list, ele, func): # Aは0-idx self.A = A self.ele = ele self.func = func self.n = len(self.A) self.num = 2 ** ((n - 1).bit_length()) self.SEG = [self.ele] * (2 * self.num) # self.LAZY=[ele]*(2*num) def search(self, idx): return self.SEG[idx + self.num] def initialize(self): for i in range(self.n): self.SEG[i + self.num] = (i + 1, self.A[i]) for i in range(self.num - 1, 0, -1): self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1]) def update(self, idx, val): # 0-idx idx += self.num self.SEG[idx] = val idx //= 2 while idx: self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1]) idx //= 2 # def delay(self,): def query(self, left, right): # maspy式。開区間のママ処理する # left, rightで値を分けているのは交換法則不成立のときのため # 開区間→Rが奇数→右端が偶数→1ずらしてから計算 #  下から上への遷移は2で割る # juppy氏は閉区間に直していた resleft = self.ele resright = self.ele left += self.num right += self.num while right - left > 0: if left % 2 == 1: resleft = self.func(resleft, self.SEG[left]) left += 1 if right % 2 == 1: right -= 1 resright = self.func(resright, self.SEG[right]) left //= 2 right //= 2 return self.func(resleft, resright)[0] ST = SegmentTree(A, (-1, infi), func) ST.initialize() for _ in range(q): a, l, r = map(int, input().split()) if a == 1: lidx, lval = ST.search(l - 1) ridx, rval = ST.search(r - 1) ST.update(ridx - 1, (ridx, lval)) ST.update(lidx - 1, (lidx, rval)) else: print(ST.query(l, r + 1))