{"trustable":false,"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":"MD","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n 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\u0027s QodeForces rating is $a_i$. \n \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$. \n \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. \n \u003cbr\u003e \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"MD","content":"The first line of the input contains an integer $T(1\\leq T\\leq2000)$, denoting the number of test cases. \n\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$. \n\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. \n\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 : \n\u003cbr\u003e\\begin{eqnarray*} \n\u003cbr\u003ea_i\u0026amp;\u003d\u0026amp;(p\\times a_{i-1}+q\\times i+r)\\bmod MOD \n\u003cbr\u003e\\end{eqnarray*} \n\u003cbr\u003eIt is guaranteed that $\\sum n\\leq 7\\times 10^7$ and $\\sum k\\leq 2\\times 10^6$. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"MD","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]$. \n\u003cbr\u003eFor each test case, you need to print a single line containing two integers $A$ and $B$, where : \n\u003cbr\u003e\\begin{eqnarray*} \n\u003cbr\u003eA\u0026amp;\u003d\u0026amp;\\sum_{i\u003d1}^{n-m+1} (maxrating_i\\oplus i)\\\\ \n\u003cbr\u003eB\u0026amp;\u003d\u0026amp;\\sum_{i\u003d1}^{n-m+1} (count_i\\oplus i) \n\u003cbr\u003e\\end{eqnarray*} \n\u003cbr\u003eNote that ``$\\oplus$\u0027\u0027 denotes binary XOR operation. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e1\n10 6 10 5 5 5 5\n3 2 2 1 5 7 6 8 2 9\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e46 11\u003c/pre\u003e"}}]}