from bisect import bisect_left, bisect_right from sortedcontainers import SortedList # セグメントツリー用の関数 def op(a, b): return a + b def e(): return 0 class SegTree: def __init__(self, n): self.n = n self.data = [e()] * (2 * n) def set(self, p, value): # Set value at position p p += self.n self.data[p] = value while p > 1: p //= 2 self.data[p] = op(self.data[2 * p], self.data[2 * p + 1]) def prod(self, l, r): # Product from index l to r-1 res = e() l += self.n r += self.n while l < r: if l % 2 == 1: res = op(res, self.data[l]) l += 1 if r % 2 == 1: r -= 1 res = op(res, self.data[r]) l //= 2 r //= 2 return res def main(): n, q, nowL = map(int, input().split()) a = SortedList() b = SortedList() x = list(map(int,input().split())) for _ in range(n): b.add(x[_]) a.add((x[_], 0)) isNotFound = True query = [] for _ in range(q): t,*cmd=list(map(int,input().split())) if t == 1: l = cmd[0] query.append([t, l]) a.add((l, len(query))) elif t == 2: l, r = cmd[0:] query.append([t, l, r]) isNotFound = False else: m = cmd[0] query.append([t, m]) if isNotFound: print("Not Found!") return idx = [] schedule = [] i = 0 for x, y in a: i += 1 idx.append([y, i, x]) schedule.append(x) idx.reverse() segArr = [0] * len(idx) while idx: if idx[-1][0] != 0: break segArr[idx[-1][1] - 1] = idx[-1][2] idx.pop() seg = SegTree(len(segArr)) for i, value in enumerate(segArr): seg.set(i, value) for q in query: if q[0] == 1: x = idx.pop() seg.set(x[1] - 1, x[2]) b.add(x[2]) elif q[0] == 2: l = q[1] r = q[2] left = bisect_left(schedule, l) right = bisect_right(schedule, r) l2 = b.bisect_left(l) r2 = b.bisect_right(r) print(r2 - l2, seg.prod(left, right)) else: nowL = q[1] if __name__ == "__main__": main()