

Problem A. Ascending RatingTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 8130 Accepted Submission(s): 2634 Problem Description Before the start of contest, there are $n$ ICPC contestants waiting in a long queue. They are labeled by $1$ to $n$ from left to right. It can be easily found that the $i$th contestant's QodeForces rating is $a_i$. Little Q, the coach of Quailty Normal University, is bored to just watch them waiting in the queue. He starts to compare the rating of the contestants. He will pick a continous interval with length $m$, say $[l,l+m1]$, and then inspect each contestant from left to right. Initially, he will write down two numbers $maxrating=1$ and $count=0$. Everytime he meets a contestant $k$ with strictly higher rating than $maxrating$, he will change $maxrating$ to $a_k$ and $count$ to $count+1$. Little T is also a coach waiting for the contest. He knows Little Q is not good at counting, so he is wondering what are the correct final value of $maxrating$ and $count$. Please write a program to figure out the answer. Input The first line of the input contains an integer $T(1\leq T\leq2000)$, denoting the number of test cases. In each test case, there are $7$ integers $n,m,k,p,q,r,MOD(1\leq m,k\leq n\leq 10^7,5\leq p,q,r,MOD\leq 10^9)$ in the first line, denoting the number of contestants, the length of interval, and the parameters $k,p,q,r,MOD$. In the next line, there are $k$ integers $a_1,a_2,...,a_k(0\leq a_i\leq 10^9)$, denoting the rating of the first $k$ contestants. To reduce the large input, we will use the following generator. The numbers $p,q,r$ and $MOD$ are given initially. The values $a_i(k<i\leq n)$ are then produced as follows : \begin{eqnarray*} a_i&=&(p\times a_{i1}+q\times i+r)\bmod MOD \end{eqnarray*} It is guaranteed that $\sum n\leq 7\times 10^7$ and $\sum k\leq 2\times 10^6$. Output Since the output file may be very large, let's denote $maxrating_i$ and $count_i$ as the result of interval $[i,i+m1]$. For each test case, you need to print a single line containing two integers $A$ and $B$, where : \begin{eqnarray*} A&=&\sum_{i=1}^{nm+1} (maxrating_i\oplus i)\\ B&=&\sum_{i=1}^{nm+1} (count_i\oplus i) \end{eqnarray*} Note that ``$\oplus$'' denotes binary XOR operation. Sample Input
Sample Output
Source  
