INF = 1 << 100 class RangeMinimumQuery(object): def __init__(self, size): self.size = size self.round_up(size) self.tree = [(INF, -1)] * (2*self.size-1) def round_up(self, n): self.size -= 1 i = 1 while self.size != (self.size | self.size >> i): self.size |= self.size >> i i *= 2 self.size += 1 def update(self, i, x): """A[i]をxに更新""" ii = i+1 i += self.size-1 self.tree[i] = (x, ii) while i > 0: i = (i-1) // 2 if self.tree[2*i+1][0] < self.tree[2*i+2][0]: self.tree[i] = self.tree[2*i+1] else: self.tree[i] = self.tree[2*i+2] def find_minimum(self, l, r): """"[l, r)の半開区間のAの最小値を返す""" def query(ql, qr, k, l, r): if qr <= l or r <= ql: return (INF, -1) if ql <= l <= r <= qr: return self.tree[k] left = query(ql, qr, 2*k+1, l, (l+r)//2) right = query(ql, qr, 2*k+2, (l+r)//2, r) if left[0] < right[0]: return left else: return right return query(l, r, 0, 0, self.size) if __name__ == '__main__': N, Q = map(int, input().split()) rmq = RangeMinimumQuery(N) for i, a in enumerate(map(int, input().split())): rmq.update(i, a) result = [] for _ in range(Q): op, l, r = map(int, input().split()) l -= 1; r -= 1 if op == 1: lval, rval = rmq.tree[l+rmq.size-1], rmq.tree[r+rmq.size-1] rmq.update(l, rval[0]) rmq.update(r, lval[0]) else: result.append(rmq.find_minimum(l, r+1)[1]) print(*result, sep='\n')