{"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\"\u003eMr. Frog has an integer sequence of length n, which can be denoted as $a_1,a_2,\\cdots ,a_n$ There are m queries.\u003cbr\u003e\u003cbr\u003eIn the i-th query, you are given two integers $l_i$ and $r_i$. Consider the subsequence $a_{l_i},a_{l_{i+1}},a_{l_{i+2}},\\cdots ,a_{r_i} $.\u003cbr\u003e\u003cbr\u003eWe can denote the positions(the positions according to the original sequence) where an integer appears first in this subsequence as $p_{1}^{(i)},p_{2}^{(i)},\\cdots, p_{k_i}^{(i)}$ (in ascending order, i.e.,$p_{1}^{(i)}\u0026lt;p_{2}^{(i)}\u0026lt;\\cdots \u0026lt;p_{k_i}^{(i)}$).\u003cbr\u003e\u003cbr\u003eNote that $k_i$ is the number of different integers in this subsequence. You should output $p_{\\left \\lceil \\frac{k_i}{2} \\right \\rceil}^{(i)}$for the i-th query.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"In the first line of input, there is an integer T ($T\\leq 2$) denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eEach test case starts with two integers n ($n \\leq \u0026#x14;2 \\times \u0026#x2;10^5$) and m ($m\\leq 2\\times \u0026#x2;10^5$). There are n integers in the next line, which indicate the integers in the sequence(i.e., $a_1,a_2,\\cdots ,a_n, 0\\leq a_i \\leq 2 \\times 10^5$).\u003cbr\u003e\u003cbr\u003eThere are two integers $l_i$ and $r_i$ in the following m lines.\u003cbr\u003e\u003cbr\u003eHowever, Mr. Frog thought that this problem was too young too simple so he became angry. He modified each query to $l_i^`,r_i^`(1\\leq l_i^` \\leq n,1\\leq r_i^` \\leq n )$. As a result, the problem became more exciting.\u003cbr\u003e\u003cbr\u003eWe can denote the answers as $ans_1, ans_2,\\cdots ,ans_m$. Note that for each test case $ans_0 \u003d 0$.\u003cbr\u003e\u003cbr\u003eYou can get the correct input $l_i,r_i$ from what you read (we denote them as $l_i^`,r_i^`$)by the following formula:\u003cbr\u003e$$ l_i \u003d min\\{ (l_i^`+ans_{i-1})\\ mod \\ n+1, (r_i^`+ans_{i-1})\\ mod \\ n+1 \\} $$\\\\$$ r_i \u003d max\\{ (l_i^`+ans_{i-1})\\ mod \\ n+1, (r_i^`+ans_{i-1})\\ mod \\ n+1 \\} $$"}},{"title":"Output","value":{"format":"HTML","content":"You should output one single line for each test case.\u003cbr\u003e\u003cbr\u003eFor each test case, output one line “Case #x: $p_1,p_2,\\cdots ,p_m$”, where x is the case number (starting from 1) and $p_1,p_2,\\cdots ,p_m$ is the answer."}},{"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\u003e2\r\n5 2\r\n3 3 1 5 4\r\n2 2\r\n4 4\r\n5 2\r\n2 5 2 1 2\r\n2 3\r\n2 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 3 3\r\nCase #2: 3 1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/bd7ab72dd09678ab6c1361f00cfd4d2c?v\u003d1714235187\"\u003e\u003cbr\u003e"}}]}