After the provincial team selection, White fell into a long period of disappointment. She could not find any hope in her results. Even so, White continued her final training before the NOI. Besides her regular training, she also began to explore topics she had never had the chance to learn during her OI days — hoping that, before saying goodbye, there would be no more regrets.
Shaking off her wandering thoughts, White suddenly focused on a problem in front of her, a plain and boring data structure problem —
White has a sequence of integers . She will perform operations on this sequence. Each operation is one of the following three types:
— Add to each element in the interval .
— Assign each element in the interval to .
— Query the value modulo .
Your task is to simulate all operations and output the results of all queries.
输入格式
The st line of the input contains integers (), representing the number of elements and the number of operations.
The nd line contains integers (), representing the initial elements.
Each of the next lines describes an operation, in one of the formats:
(, ), representing the Add operation.
(, ), representing the Assign operation.
(), representing the Query operation.
It’s guaranteed that for each during the whole process.
输出格式
For each Query operation, print an integer in a single line — the result of the query modulo .