{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows:\u003cul\u003e\u003cli\u003eThe starting position has a number of heaps, all containing some, not necessarily equal, number of beads.\u003c/li\u003e\u003cli\u003eThe players take turns chosing a heap and removing a positive number of beads from it.\u003c/li\u003e\u003cli\u003eThe first player not able to make a move, loses.\u003c/li\u003e\u003c/ul\u003eArthur and Caroll really enjoyed playing this simple game until they\r\u003cbr\u003erecently learned an easy way to always be able to find the best move:\u003cul\u003e\u003cli\u003eXor 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).\u003c/li\u003e\u003cli\u003eIf the xor-sum is 0, too bad, you will lose.\u003c/li\u003e\u003cli\u003eOtherwise, move such that the xor-sum becomes 0. This is always possible.\u003c/li\u003e\u003c/ul\u003eIt is quite easy to convince oneself that this works. Consider these facts:\u003cul\u003e\u003cli\u003eThe player that takes the last bead wins.\u003c/li\u003e\u003cli\u003eAfter the winning player\u0027s last move the xor-sum will be 0.\u003c/li\u003e\u003cli\u003eThe xor-sum will change after every move.\u003c/li\u003e\u003c/ul\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.\r\u003cbr\u003e\r\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?\r\u003cbr\u003e\r\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."}},{"title":"Input","value":{"format":"HTML","content":"Input consists of a number of test cases.\r\u003cbr\u003eFor 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.\r\u003cbr\u003eThe 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.\r\u003cbr\u003ePrint a newline after each test case."}},{"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\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eLWW\r\nWWL\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}