{"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\"\u003eYou have an array: a1, a2, , an and you must answer for some queries.\u003cbr\u003eFor each query, you are given an interval [L, R] and two numbers p and K. Your goal is to find the Kth closest distance between p and aL, aL+1, ..., aR.\u003cbr\u003eThe distance between p and ai is equal to |p - ai|.\u003cbr\u003eFor example:\u003cbr\u003eA \u003d {31, 2, 5, 45, 4 } and L \u003d 2, R \u003d 5, p \u003d 3, K \u003d 2.\u003cbr\u003e|p - a2| \u003d 1, |p - a3| \u003d 2, |p - a4| \u003d 42, |p - a5| \u003d 1.\u003cbr\u003eSorted distance is {1, 1, 2, 42}. Thus, the 2nd closest distance is 1.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer T (1 \u0026lt;\u003d T \u0026lt;\u003d 3) denoting the number of test cases.\u003cbr\u003eFor each test case:\u003cbr\u003e冘The first line contains two integers n and m (1 \u0026lt;\u003d n, m \u0026lt;\u003d 10^5) denoting the size of array and number of queries.\u003cbr\u003eThe second line contains n space-separated integers a1, a2, ..., an (1 \u0026lt;\u003d ai \u0026lt;\u003d 10^6). Each value of array is unique.\u003cbr\u003eEach of the next m lines contains four integers L\u0027, R\u0027, p\u0027 and K\u0027.\u003cbr\u003eFrom these 4 numbers, you must get a real query L, R, p, K like this: \u003cbr\u003eL \u003d L\u0027 xor X, R \u003d R\u0027 xor X, p \u003d p\u0027 xor X, K \u003d K\u0027 xor X, where X is just previous answer and at the beginning, X \u003d 0.\u003cbr\u003e(1 \u0026lt;\u003d L \u0026lt; R \u0026lt;\u003d n, 1 \u0026lt;\u003d p \u0026lt;\u003d 10^6, 1 \u0026lt;\u003d K \u0026lt;\u003d 169, R - L + 1 \u0026gt;\u003d K)."}},{"title":"Output","value":{"format":"HTML","content":"For each query print a single line containing the Kth closest distance between p and aL, aL+1, ..., aR."}},{"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\n5 2\r\n31 2 5 45 4\r\n1 5 5 1\r\n2 5 3 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}