#C5890. Array Operations

    ID: 49589 Type: Default 1000ms 256MiB

Array Operations

Array Operations

You are given an array (A) of size (N) where (A[i]) is initialized to (i+1) for (0 \leq i < N). You are also given (M) operations to perform on the array. Each operation is one of the following forms:

  • ADD X Y: Add (Y) to element at index (X) (1-indexed).
  • MULTIPLY X Y: Multiply element at index (X) (1-indexed) by (Y).

Apply all the operations sequentially and output the final state of the array.

For example, if (N = 4) and the operations are:

ADD 2 3
MULTIPLY 1 4
ADD 3 2

The resulting array will be: ( [4, 5, 5, 4] ).

inputFormat

The first line of input contains two integers (N) and (M), the number of elements in the array and the number of operations respectively. The next (M) lines each contain an operation in the form: a string (either ADD or MULTIPLY), followed by two integers (X) and (Y). Note that (X) is 1-indexed.

outputFormat

Output a single line containing (N) integers representing the final state of the array after performing all operations, with each element separated by a space. If (N = 0), output nothing.## sample

4 3
ADD 2 3
MULTIPLY 1 4
ADD 3 2
4 5 5 4