stdin = open('arbint.in', 'r')
stdout = open('arbint.out', 'w')
n, m = [int(x) for x in stdin.readline().split()]
arb = [0 for i in range(2 * n + 3)]
vec = [int(x) for x in stdin.readline().split()]
def build(pos, l, r):
if l == r:
arb[pos] = vec[l - 1]
else:
mid = (l + r) // 2
build(pos * 2, l, mid)
build(pos * 2 + 1, mid + 1, r)
arb[pos] = max(arb[pos * 2], arb[pos * 2 + 1])
def update(pos, l, r, a, b):
if l == r:
arb[pos] = b
else:
mid = (l + r) // 2
if a <= mid:
update(pos * 2, l, mid, a, b)
else:
update(pos * 2 + 1, mid + 1, r, a, b)
arb[pos] = max(arb[pos * 2], arb[pos * 2 + 1])
def query(pos, l, r, a, b):
if a <= l and r <= b:
return arb[pos]
else:
mid = (l + r) // 2
ans = 0
if a <= mid:
ans = max(ans, query(pos * 2, l, mid, a, b))
if b > mid:
ans = max(ans, query(pos * 2 + 1, mid + 1, r, a, b))
return ans
build(1, 1, n)
while(m > 0):
m -= 1
op, a, b = [int(x) for x in stdin.readline().split()]
if op == 0 :
stdout.write(str(query(1, 1, n, a, b)) + '\n')
else:
update(1, 1, n, a, b)