{"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":"给一个长度为n的数列,对于每个i \u003c\u003d n - m + 1, 有一个最大值max[i] \u003d max(a[i], a[i+1], ... a[i + m - 1]), 还有一个count[i] 表示$**从左往右**$扫描a[i]、a[i+1]、...a[i+m-1]时,最大值变化的次数。例如如果他们是:3、2、4、6,那么扫描的时候,最大值就分别是:3、3、4、6,变化次数就是3, count[i] \u003d 3,。\n\n最后输出\n$\\sum_{i\u003d1}^{n-m+1}{max[i] ~ xor ~ i }$\n和\n$\\sum_{i\u003d1}^{n-m+1}{count[i] ~ xor ~ i }$"}},{"title":"Input","value":{"format":"MD","content":"\nThe first line of the input contains an integer $T(1\\leq T\\leq2000)$, denoting the number of test cases.\n多组数据,数据输入方式比较奇葩,认真看下面的公式就好\n\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\n第一行,n,m代表数的个数和区间长度。\n剩下的数是生成序列的参数。\n\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先输入 a1,a2,...ak\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$a_i\u003d(p\\times a_{i-1}+q\\times i+r) ~mod ~MOD$\n剩下的a[i] (k\u003ci\u003c\u003dn) 按上面的公式生成。 \n\nIt is guaranteed that $\\sum n\\leq 7\\times 10^7$ and $\\sum k\\leq 2\\times 10^6$.\u003cbr\u003e"}},{"title":"Output","value":{"format":"MD","content":"每个测试样例,输出两个数:\n$\\sum_{i\u003d1}^{n-m+1}{max[i] ~ xor ~ i }$\n和\n$\\sum_{i\u003d1}^{n-m+1}{count[i] ~ xor ~ i }$"}},{"title":"Sample","value":{"format":"MD","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\u003e\u003cpre\u003e1\n10 6 10 5 5 5 5\n3 2 2 1 5 7 6 8 2 9\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e46 11\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}