#P2681. 众数

众数

Description

Alice has a sequence a1,a2,...ana_1,a_2,...a_n. Now she needs Bob to support querying the mode within a range, and also support modifying a position aia_i.

Input Format

The first line contains two integers n,mn, m.

The second line contains nn integers, representing a1,...,ana_1,...,a_n.

The next mm lines each contain three integers flag,x,yflag, x, y.

If flag=0flag=0, it queries the mode in the range [x,y]\big[x,y\big]. If there are multiple, output the smaller one.

If flag=1flag=1, it sets axa_x to yy.

Output Format

For each query with flag=0flag=0, output one integer per line representing the answer.

5 3
1 1 2 2 1
0 1 4
1 2 3
0 1 4
1
2

Hint

For 100% of the testdata, n,m1000n, m \le 1000.

For all query operations, xyx \le y.

At any time 0<ai1090 < a_i \le 10^9.

Translated by ChatGPT 5