class SegmentTree(): def __init__(self, arr, func=min, ie=2**63): self.n = 2**(len(arr) - 1).bit_length() self.ie = ie self.func = func self.tree = [ie for _ in range(2 * self.n)] for i in range(len(arr)): self.tree[self.n + i - 1] = arr[i] for i in range(self.n - 1)[::-1]: self.tree[i] = func(self.tree[2 * i + 1], self.tree[2 * i + 2]) def set(self, index, x): index += self.n - 1 self.tree[index] = x while index: index = (index - 1) // 2 self.tree[index] = self.func(self.tree[2 * index + 1], self.tree[2 * index + 2]) def query(self, left, right): if right <= left: return self.ie left += self.n - 1 right += self.n - 2 tmp_l = self.ie tmp_r = self.ie while right - left > 1: if left & 1 == 0: tmp_l = self.func(tmp_l, self.tree[left]) if right & 1 == 1: tmp_r = self.func(self.tree[right], tmp_r) right -= 1 left = left // 2 right = (right - 1) // 2 if left == right: tmp_l = self.func(tmp_l, self.tree[left]) else: tmp_l = self.func( self.func(tmp_l, self.tree[left]), self.tree[right]) return self.func(tmp_l, tmp_r) N, Q = map(int, input().split()) X = list(map(int, input().split())) A = [(X[i], i + 1) for i in range(N)] st = SegmentTree(A, min, (2**63, None)) ans = [] for _ in range(Q): q, l, r = map(int, input().split()) if q == 1: al = st.query(l - 1, l)[0] ar = st.query(r - 1, r)[0] st.set(l - 1, (ar, l)) st.set(r - 1, (al, r)) else: ans.append(st.query(l - 1, r)[1]) print('\n'.join(map(str, ans)))