This page is still under construction.

Parts of this page are still being built. What you see may change.

Subtract if Greater!

Time limit5sMemory limit512 MB

Summary
Maintain a multiset under queries that ask for the k-th smallest element and queries that subtract x from every element greater than x, then report each k-th smallest.
Level

Hard8 of 10

Topics
Segment tree, Binary search, Sorting, Implementation
Solved
No attempts yet

Problem

Consider a multiset AA consisting of nn elements: a1,a2,…,ana_1, a_2, \ldots, a_n.

We define two types of operations that can be performed on this multiset:

  1. Given xix_i, print the number that would be the xix_i-th element if we sort the multiset in non-decreasing order.
  2. Given xix_i, subtract xix_i from all elements of AA that are strictly greater than xix_i.

Perform the qq given operations in the given order and output the results of all operations of the first type.

Input

The first line contains two integers nn and qq: the size of the multiset AA and the number of queries (1≤n≤1051 \le n \le 10^5, 1≤q≤1061 \le q \le 10^6).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9): the elements of AA.

Each of the next qq lines describes a single operation. An operation is given as two integers tit_i and xix_i: the type and the parameter of the operation. It is guaranteed that ti∈{1,2}t_i \in \{1, 2\}. If ti=1t_i = 1, then 1≤xi≤n1 \le x_i \le n. If ti=2t_i = 2, then 1≤xi≤1091 \le x_i \le 10^9.

It is guaranteed that there is at least one operation of type 11.

The elements of AA are given in arbitrary order.

Output

For each operation of the first type, output the xix_i-th element in non-decreasing order. Separate the answers with line breaks.

Examples3

  1. Example 1

    Input
    4 5
    1 5 6 12
    2 5
    1 1
    1 2
    1 3
    1 4
    
    Expected output
    1
    1
    5
    7
    
  2. Example 2

    Input
    5 4
    1 10 5 4 2
    2 1
    1 5
    2 3
    1 2
    
    Expected output
    9
    1
    
  3. Example 3

    Input
    3 2
    3 2 1
    2 10000
    1 3
    
    Expected output
    3