{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eBefore 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\u0027s QodeForces rating is $a_i$.\u003cbr\u003eLittle 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+m-1]$, and then inspect each contestant from left to right. Initially, he will write down two numbers $maxrating\u003d-1$ and $count\u003d0$. Everytime he meets a contestant $k$ with strictly higher rating than $maxrating$, he will change $maxrating$ to $a_k$ and $count$ to $count+1$.\u003cbr\u003eLittle 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.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T(1\\leq T\\leq2000)$, denoting the number of test cases.\u003cbr\u003eIn 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$.\u003cbr\u003eIn 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.\u003cbr\u003eTo 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\u0026lt;i\\leq n)$ are then produced as follows :\u003cbr\u003e\\begin{eqnarray*}\u003cbr\u003ea_i\u0026amp;\u003d\u0026amp;(p\\times a_{i-1}+q\\times i+r)\\bmod MOD\u003cbr\u003e\\end{eqnarray*}\u003cbr\u003eIt is guaranteed that $\\sum n\\leq 7\\times 10^7$ and $\\sum k\\leq 2\\times 10^6$.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Since the output file may be very large, let\u0027s denote $maxrating_i$ and $count_i$ as the result of interval $[i,i+m-1]$.\u003cbr\u003eFor each test case, you need to print a single line containing two integers $A$ and $B$, where :\u003cbr\u003e\\begin{eqnarray*}\u003cbr\u003eA\u0026amp;\u003d\u0026amp;\\sum_{i\u003d1}^{n-m+1} (maxrating_i\\oplus i)\\\\\u003cbr\u003eB\u0026amp;\u003d\u0026amp;\\sum_{i\u003d1}^{n-m+1} (count_i\\oplus i)\u003cbr\u003e\\end{eqnarray*}\u003cbr\u003eNote that ``$\\oplus$\u0027\u0027 denotes binary XOR operation.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n10 6 10 5 5 5 5\r\n3 2 2 1 5 7 6 8 2 9\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e46 11\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}