Under construction

Still being built. Things may change

Expressions

Time limit2sMemory limit1024 MB

Summary
Given an expression of positive integers with +, -, and * and a series of single-value changes, report whether the value is odd or even before and after each change.
Level

Medium6 of 10

Topics
Segment tree, Math, Implementation
Solved
No attempts yet

Problem

Part of the training in arithmetic classes at Tomorrow Programming School is evaluating a given arithmetic expression quickly, in your head only. The expressions contain only positive integers, no brackets, and only three operations: addition, subtraction, and multiplication. The result is therefore guaranteed to be an integer. At introductory stages, a student only has to find the parity of the result: is it odd or even?

Unfortunately, the professor who writes the expressions on the blackboard is quite absentminded. He often rewrites various numbers in an expression, sometimes several more times while the students are already calculating. A rewrite usually changes the value of the whole expression, so the students have to start over.

The students decided to write a program to help them. The input is the original expression and the sequence of subsequent value changes. For each change, the program calculates the value of the modified expression, reusing earlier work where possible instead of recalculating from scratch.

Input

The first line contains two integers NN and MM (1≤N,M≤1051 \le N, M \le 10^5), the number of integers in the expression and the number of subsequent value changes. The second line contains NN space-separated tokens. Each token is an integer AiA_i (1≤Ai≤1091 \le A_i \le 10^9) or one of +, -, * (addition, subtraction, multiplication). Each of the next MM lines contains two space-separated numbers XX (1≤X≤N1 \le X \le N) and YY (1≤Y≤1091 \le Y \le 10^9), meaning the XX-th number in the expression is changed to YY.

The changes are applied in order. When a later change targets a different position, the earlier change stays in effect.

Output

Output M+1M + 1 lines. Line ii is even or odd, depending on whether the expression evaluates to an even or odd value after the first i−1i - 1 changes. The first line gives the answer before any change. The expression follows standard operator precedence: multiplication is evaluated before addition and subtraction.

Examples1

  1. Example 1

    Input
    6 4
    11 + 22 * 33 - 44 * 55 * 66
    1 2
    2 3
    4 5
    3 5
    
    Expected output
    odd
    even
    odd
    odd
    odd