{"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\"\u003eAlice has received a beautiful present from Bob. The present contains n lanterns and m switches. Each switch controls some lanterns and pushing the switch will change the state of all lanterns it controls from off to on or from on to off. A lantern may be controlled by many switches. At the beginning, all the lanterns are off. \u003cbr\u003e\u003cbr\u003eAlice wants to change the state of the lanterns to some specific configurations and she knows that pushing a switch more than once is pointless. Help Alice to find out the number of ways she can achieve the goal. Two ways are different if and only if the sets (including the empty set) of the switches been pushed are different.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer T (T\u0026lt;\u003d5) indicating the number of test cases.\u003cbr\u003eThe first line of each test case contains an integer n (1\u0026lt;\u003dn\u0026lt;\u003d50) and m (1\u0026lt;\u003dm\u0026lt;\u003d50).\u003cbr\u003eThen m lines follow. Each line contains an integer k (k\u0026lt;\u003dn) indicating the number of lanterns this switch controls.\u003cbr\u003eThen k integers follow between 1 and n inclusive indicating the lantern controlled by this switch.\u003cbr\u003eThe next line contains an integer Q (1\u0026lt;\u003dQ\u0026lt;\u003d1000) represent the number of queries of this test case.\u003cbr\u003eQ lines follows. Each line contains n integers and the i-th integer indicating that the state (1 for on and 0 for off) of the i-th lantern of this query.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print the case number in the first line. Then output one line containing the answer for each query.\u003cbr\u003ePlease follow the format of the sample output."}},{"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\n3 2\r\n2 1 2\r\n2 1 3\r\n2\r\n0 1 1\r\n1 1 1\r\n3 3\r\n0\r\n0\r\n0\r\n2\r\n0 0 0\r\n1 0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1:\r\n1\r\n0\r\nCase 2:\r\n8\r\n0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}