{"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":"HTML","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 XOR is a kind of bit operator, we define that as follow: for two binary base number A and B, let C\u003dA XOR B, then for each bit of C, we can get its value by check the digit of corresponding position in A and B. And for each digit, 1 XOR 1 \u003d 0, 1 XOR 0 \u003d 1, 0 XOR 1 \u003d 1, 0 XOR 0 \u003d 0. And we simply write this operator as ^, like 3 ^ 1 \u003d 2,4 ^ 3 \u003d 7. XOR is an amazing operator and this is a question about XOR. We can choose several numbers and do XOR operatorion to them one by one, then we get another number. For example, if we choose 2,3 and 4, we can get 2^3^4\u003d5. Now, you are given N numbers, and you can choose some of them(even a single number) to do XOR on them, and you can get many different numbers. Now I want you tell me which number is the K-th smallest number among them. \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line of the input is a single integer T(T\u0026lt;\u003d30), indicates there are T test cases. \n\u003cbr\u003eFor each test case, the first line is an integer N(1\u0026lt;\u003dN\u0026lt;\u003d10000), the number of numbers below. The second line contains N integers (each number is between 1 and 10^18). The third line is a number Q(1\u0026lt;\u003dQ\u0026lt;\u003d10000), the number of queries. The fourth line contains Q numbers(each number is between 1 and 10^18) K1,K2,......KQ."}},{"title":"Output","value":{"format":"HTML","content":"For each test case,first output Case #C: in a single line,C means the number of the test case which is from 1 to T. Then for each query, you should output a single line contains the Ki-th smallest number in them, if there are less than Ki different numbers, output -1."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n2\n1 2\n4\n1 2 3 4\n3\n1 2 3\n5\n1 2 3 4 5\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eCase #1:\n1\n2\n3\n-1\nCase #2:\n0\n1\n2\n3\n-1\n\n\n \n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\nIf you choose a single number, the result you get is the number you choose.\nUsing long long instead of int because of the result may exceed 2^31-1.\n\n \n \u003c/pre\u003e"}}]}