{"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\"\u003eArthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows:\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The starting position has a number of heaps, all containing some, not necessarily equal, number of beads.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The players take turns chosing a heap and removing a positive number of beads from it.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The first player not able to make a move, loses.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eArthur and Caroll really enjoyed playing this simple game until they recently learned an easy way to always be able to find the best move:\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;Xor the number of beads in the heaps in the current position (i.e. if we have 2, 4 and 7 the xor-sum will be 1 as 2 xor 4 xor 7 \u003d 1).\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;If the xor-sum is 0, too bad, you will lose.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;Otherwise, move such that the xor-sum becomes 0. This is always possible.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eIt is quite easy to convince oneself that this works. Consider these facts:\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The player that takes the last bead wins.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;After the winning player\u0027s last move the xor-sum will be 0.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The xor-sum will change after every move.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eWhich means that if you make sure that the xor-sum always is 0 when you have made your move, your opponent will never be able to win, and, thus, you will win. \u003cbr\u003e\u003cbr\u003eUnderstandibly it is no fun to play a game when both players know how to play perfectly (ignorance is bliss). Fourtunately, Arthur and Caroll soon came up with a similar game, S-Nim, that seemed to solve this problem. Each player is now only allowed to remove a number of beads in some predefined set S, e.g. if we have S \u003d(2, 5) each player is only allowed to remove 2 or 5 beads. Now it is not always possible to make the xor-sum 0 and, thus, the strategy above is useless. Or is it? \u003cbr\u003e\u003cbr\u003eyour job is to write a program that determines if a position of S-Nim is a losing or a winning position. A position is a winning position if there is at least one move to a losing position. A position is a losing position if there are no moves to a losing position. This means, as expected, that a position with no legal moves is a losing position.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Input consists of a number of test cases. For each test case: The first line contains a number k (0 \u0026lt; k ≤ 100 describing the size of S, followed by k numbers si (0 \u0026lt; si ≤ 10000) describing S. The second line contains a number m (0 \u0026lt; m ≤ 100) describing the number of positions to evaluate. The next m lines each contain a number l (0 \u0026lt; l ≤ 100) describing the number of heaps and l numbers hi (0 ≤ hi ≤ 10000) describing the number of beads in the heaps. The last test case is followed by a 0 on a line of its own."}},{"title":"Output","value":{"format":"HTML","content":"For each position: If the described position is a winning position print a \u0027W\u0027.If the described position is a losing position print an \u0027L\u0027. Print a newline after each test case.\u003cbr\u003e"}},{"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 2 5\r\n3\r\n2 5 12\r\n3 2 4 7\r\n4 2 3 7 12\r\n5 1 2 3 4 5\r\n3\r\n2 5 12\r\n3 2 4 7\r\n4 2 3 7 12\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eLWW\r\nWWL\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}