#K56757. Modify Array with Operations

    ID: 30269 Type: Default 1000ms 256MiB

Modify Array with Operations

Modify Array with Operations

You are given an array of ( n ) integers and ( t ) operations. In each operation, you are provided with two indices ( l ) and ( r ) (0-indexed). For the subarray ( a[l...r] ), compute ( S = \sum_{i=l}^{r} a_i ) and then update every element in this subarray to ( S \bmod m ), where ( m ) is a given integer. The operations are performed sequentially. Your task is to modify the array according to these operations and output the final array.

inputFormat

The first line contains three integers ( n ), ( t ), and ( m ). The second line contains ( n ) space-separated integers representing the array. Each of the next ( t ) lines contains two integers ( l ) and ( r ) indicating an operation.

outputFormat

Output the modified array as a sequence of ( n ) space-separated integers.## sample

5 2 10
1 2 3 4 5
1 3
0 4
3 3 3 3 3