Joker's Card Trick

After each point update to a row of nonzero integers, find the smallest prefix index maximizing the running sum of values scaled by the total positive and total negative sums.

Hard8Segment treePrefix sumGreedyMathNo attempts yetTime limit3sMemory limit512 MB

Problem

Joker is preparing a new card trick that needs some arithmetic. Help him with the calculation.

A row holds nn cards, and card ii carries a nonzero integer aia_i. Let PP be the sum of all positive numbers in the row, and let NN be the sum of all negative numbers. Card ii has weight wi=ai/Pw_i = a_i / P when ai>0a_i > 0, and wi=ai/Nw_i = a_i / |N| when ai<0a_i < 0.

Let si=j=1iwjs_i = \sum_{j=1}^{i} w_j. Joker wants the position ii with the largest sis_i. If several positions give that largest value, he takes the smallest one.

A trick with a fixed row is boring. Joker changes the numbers written on the cards, and after every change he wants the position with the largest sis_i again.

Input

The first line contains two integers nn and mm, the number of cards and the number of changes (1n,m500001 \le n, m \le 50000).

The second line contains nn integers aia_i, the numbers written on the cards at the start (109ai109-10^9 \le a_i \le 10^9, ai0a_i \ne 0).

Each of the next mm lines contains two integers pip_i and viv_i, meaning that the number on the card at position pip_i becomes viv_i (1pin1 \le p_i \le n, 109vi109-10^9 \le v_i \le 10^9, vi0v_i \ne 0).

At every moment the row contains at least one card with a positive number and at least one card with a negative number. The sum of the positive numbers never exceeds 10910^9, and the sum of the absolute values of the negative numbers never exceeds 10910^9.

Output

Print m+1m+1 lines.

On the first line print the position with the largest sis_i for the initial numbers. On each of the following mm lines print the position with the largest sis_i right after the corresponding change, one position per line.