Memory Manager
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 N and supports three advanced operations:
copy(a, b, l) - Copies the segment from indices a to a+l-1 to the segment starting at b to b+l-1.
sum(l, r) - Computes the sum of the array elements from index l to r.
print(l, r) - Outputs the elements from index l to r, 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.
Input
The first line of the input contains an integer N (1 ≤ N ≤ 1000000), which is the size of the array that your memory manager will handle.
The second line provides four integers 1 ≤ X_1, A, B, M ≤ 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*X_i+B) mod M.
The third line contains an integer K (1 ≤ K ≤ 200000), representing the number of queries that your memory manager must process.
The next K 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 ≤ r.
out l r - Corresponds to the print operation, where l ≤ r.
It is guaranteed that the total length of all print queries does not exceed 3000. Additionally, all queries are guaranteed to be valid.
Output
For each sum or print query, output the result on a separate line in the output file.