Weather Forecast

Maintain N snow depths under point increments and decrements, then answer range-count queries (depth between L and R) and T-th largest value queries online.

Hard8Segment treeBinary searchSortingCombinatoricsNo attempts yetTime limit2sMemory limit128 MB

Problem

Snow falls all day long in Snowflake Country. It keeps piling up, and it keeps melting.

Taekhee, the weather caster of Snowflake Country, talks about nothing but snow. Earthquake or typhoon, the forecast always has the same shape.

Snow now measures between LLmm and RRmm in A, B, C, ..., X and KK regions in total.

An administrative reform split the country into NN regions, and reading out KK region names one by one became too much work. So Taekhee decided to report only the count KK of regions whose snow depth is between LLmm and RRmm. That number alone says nothing about any single region, so Taekhee also reports the depth of the region with the TT-th deepest snow. With so many regions, doing this by hand is hopeless. Taekhee wants a program that tracks the snow depths automatically.

The program handles four operations.

  1. Region ii gains xxmm of snow.
  2. Region ii loses yymm of snow to melting.
  3. Count the regions whose snow depth is at least LLmm and at most RRmm.
  4. Report the snow depth of the region with the TT-th deepest snow.

Operation 4 counts equal depths separately. For example, if five regions hold (3,1,2,1,2)(3, 1, 2, 1, 2), then for TT equal to 1, 2, 3, 4, 5 the answers are 3, 2, 2, 1, 1 in that order.

A forecast has to be fast, so the program has to be fast. Write it for Taekhee.

Input

The first line contains the number of regions NN and the number of commands MM. (1N,M1051 \le N, M \le 10^5)

The second line contains the current snow depths S1,S2,,SNS_1, S_2, \dots, S_N. (0Si1090 \le S_i \le 10^9)

Each of the next MM lines contains one command in one of the following four forms.

  • 1 i x: region ii gains xxmm of snow. (1iN1 \le i \le N, 1x1091 \le x \le 10^9)
  • 2 i y: region ii loses yymm of snow. (1iN1 \le i \le N, 1y1091 \le y \le 10^9)
  • 3 L R: count the regions whose snow depth is at least LLmm and at most RRmm. (0LR10180 \le L \le R \le 10^{18})
  • 4 T: report the snow depth of the region with the TT-th deepest snow. (1TN1 \le T \le N)

No command of type 2 ever makes a snow depth negative.

Output

For each command of type 3 and each command of type 4, print the answer as one integer on its own line.