PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SRD0000083. Học máy và tần suất (Machine Learning)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Học máy và tần suất (Machine Learning)

Machine Learning

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a sequence of positive integers a1,a2,…,ana_1,a_2,\ldots,a_n. Process two types of operations in their original order. Query 1 l r: for each nonnegative integer value vv, let cvc_v denote its frequency in al,…,ara_l,\ldots,a_r. Output the minimum excluded nonnegative integer (MEX) of the set {c0,c1,…,c109}\{c_0,c_1,\ldots,c_{10^9}\}. Query 2 p x: assign ap=xa_p=x. All array elements are positive, hence c0=0c_0=0 and the required MEX is positive. Each query uses the array after all preceding updates.

Input

The first line contains n,qn,q. The second line contains nn integers a1,…,ana_1,\ldots,a_n. Each of the next qq lines contains exactly three integers in one of the forms 1 l r or 2 p x. Indices are 1-based and query ranges are inclusive.

Output

For every type-1 operation, output the required MEX on its own line. Type-2 operations produce no output.

Subtasks

  • Subtask 1 (10 points): 1≤n≤401\le n\le 40; 1≤q≤601\le q\le 60. 1≤ai,x≤1091\le a_i,x\le 10^9; 1≤l≤r≤n1\le l\le r\le n; 1≤p≤n1\le p\le n.

  • Subtask 2 (20 points): 1≤n≤20001\le n\le 2000; 1≤q≤20001\le q\le 2000. 1≤ai,x≤1091\le a_i,x\le 10^9; 1≤l≤r≤n1\le l\le r\le n; 1≤p≤n1\le p\le n.

  • Subtask 3 (30 points): 1≤n≤200001\le n\le 20000; 1≤q≤200001\le q\le 20000. 1≤ai,x≤1091\le a_i,x\le 10^9; 1≤l≤r≤n1\le l\le r\le n; 1≤p≤n1\le p\le n.

  • Subtask 4 (40 points): 1≤n≤1000001\le n\le 100000; 1≤q≤1000001\le q\le 100000. 1≤ai,x≤1091\le a_i,x\le 10^9; 1≤l≤r≤n1\le l\le r\le n; 1≤p≤n1\le p\le n.

Examples

Input

10 4
1 2 3 1 1 2 2 2 9 9
1 1 1
1 2 8
2 7 1
1 2 8

Output

2
3
2

Explanation

For the first query the only positive frequency is 1, so the MEX is 2. Before the update, positive frequencies in [2,8][2,8] are 1, 2 and 4, yielding MEX 3. After assigning a7=1a_7=1, the positive frequencies become 1 and 3, yielding MEX 2.