merge
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

a is a permutation of , the original values are given.

There are M operations, each of them is of one of two types:

, means replacing  with .

, means that you need to answer the value a_i .

Where merge(a,b) means the following code:

def merge(a,b):
  c=[]
  while a.size() and b.size():
    if a[0]<b[0]:
      c.append(a[0])
      a.pop_front()
    else:
      c.append(b[0])
      b.pop_front()
  return c+a+b

输入描述:

The first line contains two integer N,M .

The second line contains N integers .

For the following M lines, each line is of format  or .

输出描述:

For each operation of the second type, output a line containing the answer.
示例1

输入

复制
5 3
2 3 1 4 5
2 3
1 1 3 5
2 3

输出

复制
1
1

备注: