{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAlice and Bob love playing the Nim game (if you do not remember the rules, please refer to the Notes section). They played it so many times that they learned how to determine the winner at a first glance: if there are $$$a_1$$$, ..., $$$a_n$$$ stones in the heaps, the first player wins if and only if the bitwise xor $$$a_1 \\oplus \\ldots \\oplus a_n$$$ is nonzero.\u003c/p\u003e\u003cp\u003eThey heard that in some online games players pick their characters before the game, adding a strategic layer. Why not do it with Nim?\u003c/p\u003e\u003cp\u003eThey came up with the following version. Alice and Bob each have several boxes with heaps. In the first phase they pick exactly one heap from each box. In the second phase Alice chooses some nonempty subset of those heaps, and the regular Nim game starts on chosen heaps with Bob to move first.\u003c/p\u003e\u003cp\u003eBob already knows which heaps Alice picked. Help him to perform his picks so that he wins the game no matter which heaps Alice chooses during the second phase.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eOn the first line, there is a single integer $$$n$$$ ($$$0 \\leq n \\leq 60$$$), the number of heaps picked by Alice.\u003c/p\u003e\u003cp\u003eIf $$$n \u0026gt; 0$$$, on the next line there are $$$n$$$ integers: the sizes of those heaps. Otherwise, this line is omitted.\u003c/p\u003e\u003cp\u003eOn the next line there is a single number $$$m$$$ ($$$1 \\leq m \\leq 60$$$), the number of Bob\u0027s boxes.\u003c/p\u003e\u003cp\u003eEach of the next $$$m$$$ lines contains the description of a box. Each description starts with a number $$$k_i$$$ ($$$1 \\leq k_i \\leq 5000$$$), the number of heaps in the box. Then $$$k_i$$$ numbers follow, denoting the sizes of those heaps.\u003c/p\u003e\u003cp\u003eThe size of each heap is between $$$1$$$ and $$$2^{60} - 1$$$, inclusive. The total number of heaps in Bob\u0027s boxes does not exceed $$$5000$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIf Bob cannot win (that is, no matter what he picks, Alice can make such a choice that the resulting Nim position is losing), print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e-1\u003c/span\u003e\" (without quotes). Otherwise, print $$$m$$$ integers: the sizes of the heaps Bob should pick from his boxes in the same order in which the boxes are given in the input.\u003c/p\u003e"}},{"title":"Examples","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\n1 2\n2\n2 1 2\n3 1 2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\n5\n2\n3 1 2 3\n4 4 5 6 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the game of Nim, there are several heaps of stones. On each turn, the player selects any heap and takes some positive number of stones from it. The player who takes the last stone wins the game.\u003c/p\u003e"}}]}