---
category_name: medium
problem_code: HILLJUMP
problem_name: 'Hill Jumping'
languages_supported:
- ADA
- ASM
- BASH
- BF
- C
- 'C99 strict'
- CAML
- CLOJ
- CLPS
- 'CPP 4.3.2'
- 'CPP 6.3'
- CPP14
- CS2
- D
- ERL
- FORT
- FS
- GO
- HASK
- ICK
- ICON
- JAVA
- JS
- 'LISP clisp'
- 'LISP sbcl'
- LUA
- NEM
- NICE
- NODEJS
- 'PAS fpc'
- 'PAS gpc'
- PERL
- PERL6
- PHP
- PIKE
- PRLG
- PYPY
- PYTH
- 'PYTH 3.5'
- RUBY
- SCALA
- 'SCM chicken'
- 'SCM guile'
- 'SCM qobi'
- ST
- TCL
- TEXT
- WSPC
max_timelimit: '2'
source_sizelimit: '50000'
problem_author: kingofnumbers
problem_tester: null
date_added: 20-10-2016
tags:
- aug17
- bruteforce
- kingofnumbers
- medium
- sqrt
editorial_url: 'https://discuss.codechef.com/problems/HILLJUMP'
time:
view_start_date: 1503048600
submit_start_date: 1503048600
visible_start_date: 1503048600
end_date: 1735669800
current: 1514816323
layout: problem
---
All submissions for this problem are available.### Read problems statements in [mandarin chinese](http://www.codechef.com/download/translated/AUG17/mandarin/HILLJUMP.pdf), [russian](http://www.codechef.com/download/translated/AUG17/russian/HILLJUMP.pdf) and [vietnamese](http://www.codechef.com/download/translated/AUG17/vietnamese/HILLJUMP.pdf) as well.
Chef is going to organize a hill jumping competition and he is going to be one of the judges in it. In this competition there are **N** hills in a row, and the initial height of i-th hill is **Ai**. Participants are required to demonstrate their jumping skills by doing what the judges tell them.
Judges will give each participant a card which has two numbers, **i** and **k**, which means that the participant should start at the **i**-th hill and jump **k** times, where one jump should be from the current hill to the nearest hill to the right which is strictly higher (in height) than the current one. If there is no such hill or its distance (i.e. difference between their indices) is more than 100 then the participant should remain in his current hill.
Please help Chef by creating a program to use it during the competitions. It should read the initial heights of the hill and should support two kinds of operations:
Type 1: Given a two numbers: **i** and **k**, your program should output the index of the hill the participant is expected to finish if he starts from the i-th hill (as explained above).
Type 2: Given three numbers: **L**, **R**, **X**, the heights of all the hills between **L** and **R**, both end points inclusive, should be increased by **X** (if **X** is negative then their height is decreased).
### Input
- First line contains two integers **N** and **Q**, denoting the number of hills and number of operations respectively.
- Second line contains **N** space-separated integers **A1**, **A2**, ..., **AN** denoting the initial heights of the hills.
- Each of the next **Q** lines describes an operation. If the first integer is equal to 1, it means that the operation is of Type 1, and it will be followed by two integers **i** and **k**. Otherwise the first number will be equal to 2, and it means that the operation is of Type 2, and so it will be followed by three integers **L**, **R** and **X**.
### Output
For each operation of Type 1, output the index of the hill in which the participant will finish.
### Constraints
- 1 ≤ **N, Q** ≤ 100,000
- 1 ≤ **Ai** ≤ 1,000,000
- 1 ≤ **L** ≤ **R** ≤ N
- -1,000,000 ≤ **X** ≤ 1,000,000
- 1 ≤ **i**, **k** ≤ N
### Subtasks
- **Subtask 1** (20 points) : 1 ≤ **N, Q** ≤ 1,000
- **Subtask 2** (80 points) : Original constraints
### Example
<pre><b>Input:</b>
5 3
1 2 3 4 5
1 1 2
2 3 4 -1
1 1 2
<b>Output:</b>
3
4
</pre>### Explanation
The initial heights are (1, 2, 3, 4, 5). The first operation is of Type 1 and starts from Hill 1 and wants to jump twice. The first jump will be to Hill 2, and the second jump will be to Hill 3. Hence the output for this is 3.
The second operation changes the heights to (1, 2, 2, 3, 5).
The last operation starts from Hill 1. The first jump is to Hill 2. But the next jump will skip Hill 3 (because it's height is not strictly greater than the current hill's height), and will go to Hill 4. Hence the output is 4.