Under construction

Still being built. Things may change

The Great Battle

Time limit5sMemory limit1024 MB

Summary
Given gods with strengths, handle range decrements and, for each query, find which god in a range first drives Kratos's power to zero.
Level

Medium7 of 10

Topics
Segment tree, Simulation
Solved
No attempts yet

Statement

Recovering from the last fight, Kratos sets out on another journey. He decides to climb Mount Olympus together with the Titans and fight the greatest battle yet.

At the summit he sees nn gods. After watching them, Kratos sizes up the strength of each one. God number ii has strength sis_i.

Fighting gods is hard, so after a battle with god ii, Kratos's power TT becomes ⌊Tsi⌋\lfloor \frac{T}{s_i} \rfloor. When TT drops to zero, Kratos dies.

Over time, some gods standing next to each other grow tired, and their strength drops by one. In other words, a query (l,r)(l, r) means that for every god ii at position ll through rr, si=max⁡(si−1,1)s_i = \max(s_i - 1, 1).

During the fight, Kratos makes plans. Plan number jj means Kratos fights gods lj,lj+1,…,rjl_j, l_j + 1, \dots, r_j in order, starting with power xjx_j. For each plan he wants to know whether he survives it. If he dies, he wants to know which god lands the last blow.

For each plan, print the number of the god who kills Kratos. If Kratos survives, print <<-1>>.

Input

The first line contains two integers nn and qq, the number of gods and the number of queries (1≤n,q≤500 0001 \leq n, q \leq 500\,000). The second line contains nn integers s1,s2,…,sns_1, s_2, \dots, s_n, the strengths of the gods (1≤si≤1091 \leq s_i \leq 10^9). Each of the next qq lines is a query, and its first number is the type typetype.

If type=1type = 1, two integers ll and rr follow (1≤l≤r≤n1 \leq l \leq r \leq n). The strength of the gods from ll to rr decreases by one.

If type=2type = 2, three integers ll, rr, and xx follow: the number of the first god, the number of the last god, and Kratos's starting power for this plan (1≤l≤r≤n1 \leq l \leq r \leq n, 1≤x≤1091 \leq x \leq 10^9).

Output

For each query of type 2, print the number of the god who kills Kratos. If Kratos is still alive after the plan, print <<-1>>.

Hint

In the first query of the first sample, Kratos starts with power 61. After the first fight, it is ⌊611⌋=61\lfloor \frac{61}{1} \rfloor = 61. Then the power becomes 30, 10, 5, 1, 1, and 1 in turn.

Examples2

  1. Example 1

    Input
    6 4
    1 2 3 2 3 1
    2 1 6 61
    2 1 3 2
    1 1 3
    2 1 3 2
    
    Expected output
    -1
    3
    -1
    
  2. Example 2

    Input
    3 3
    100 200 300
    2 2 3 500
    1 1 3
    2 1 3 5890598
    
    Expected output
    3
    3