One of the key innovations in the latest operating system, Indows 7, is its new memory manager. This manager operates on an array of length and supports three advanced operations:
copy(, , ) - Copies the segment from indices [a, a+l-1] to the segment starting at [b, b+l-1].
sum(, ) - Computes the sum of the array elements from index to .
print(, ) - Outputs the elements from index to , inclusive.
As a developer of your own operating system, incorporating such innovative technologies is essential. Your task is to implement a memory manager with these exact capabilities.
The first line of the input contains an integer (1 \leq N \leq 1000000), which is the size of the array that your memory manager will handle.
The second line provides four integers 1 \leq X_1, A, B, M \leq 10^9+10. These numbers are used to generate the initial array of numbers X_1, X_2, ..., X_N using the formula X_{i+1} = (A \cdot X_i + B) \bmod M.
The third line contains an integer (1 \leq K \leq 200000), representing the number of queries that your memory manager must process.
The next lines contain the queries, formatted as follows:
cpy a b l - Corresponds to the copy operation.
sum l r - Corresponds to the sum operation, where l \leq r.
out l r - Corresponds to the print operation, where l \leq r.
It is guaranteed that the total length of all print queries does not exceed . Additionally, all queries are guaranteed to be valid.
For each sum or print query, output the result on a separate line in the output file.
Beispiel 1