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

#SRD0000050. Nhảy qua các ngọn đồi (Hill Jumping)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Nhảy qua các ngọn đồi (Hill Jumping)

Hill Jumping

Source: CodeChef

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn hills of heights aia_i. From hill ii, a participant jumps to the nearest strictly higher hill to the right, provided its index distance is at most 100100. If no such hill exists, all remaining jumps leave the participant in place.

Process:

  • 1 i k: report the final hill after up to kk prescribed jumps from hill ii.
  • 2 L R X: add the integer XX (possibly negative) to all hill heights in the inclusive interval.

All jump queries use the current heights.

Input

The first line contains n,qn,q, followed by the initial heights. Each operation is 1 i k or 2 L R X; 1≤i,k≤n1\le i,k\le n and 1≤L≤R≤n1\le L\le R\le n.

Output

Print the final hill index for every type-1 query.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10001\le n\le1000; 1≤q≤10001\le q\le1000. The original 20%/80% scoring split; each jump may inspect at most the next 100 positions.
  • Subtask 2 (80 points): 1≤n≤1000001\le n\le100000; 1≤q≤1000001\le q\le100000. The original 20%/80% scoring split; each jump may inspect at most the next 100 positions.

Examples

Input

5 3
1 2 3 4 5
1 1 2
2 3 4 -1
1 1 2

Output

3
4

Explanation

The first query jumps from hill 11 to hill 22 and then hill 33, yielding 3. After subtracting one from hills 33 and 44, heights become (1,2,2,3,5)(1,2,2,3,5). From hill 11, the participant reaches 22, skips equally high hill 33, and reaches hill 44, yielding 4.