Nim is a famous game in which two players take turns removing items from $n$ distinct piles. During each turn, a player must remove one or more items from a single, non-empty pile. The winner of the game is whichever player removes the last item from the last non-empty pile.

John and Kate modified Nim by adding the following rule, which they call a Zero-Move:

For each non-empty pile, either player can remove $0$ items from that pile and have it count as their move; however, this move can only be performed once per pile by either player. For example, let's say pile $\boldsymbol{i}$ initially has $p_i=2$ items in it. If John decides to use a Zero-Move on pile $\boldsymbol{i}$, then neither John nor Kate can perform another Zero-Move on pile $\boldsymbol{i}$; that said, either player is free to perform a Zero-Move on any other non-empty pile that hasn't had a Zero-Move performed on it yet.

John and Kate play $\mathrm{~g~}$ games of Zero-Move Nim. Given the number of items in each pile for each game, determine whether or not John can win the game if he always moves first and each player always moves optimally (i.e., never makes a move that causes them to lose if some better, winning move exists). For each game, print W on a new line if John can win; otherwise, print L instead.

Input Format

The first line contains an integer, $\mathrm{~g~}$, denoting the number of games. The $2\cdot g$ subsequent lines describe each game over two lines:

The first line contains an integer, $n$, denoting the number of heaps.
The second line contains $n$ space-separated integers describing $p_0,p_1,\ldots,p_{n-1}$. 

Constraints

$1\leq g\leq10$  
$1\leq n\leq10$  
$1\leq p_i<2^{30}$  

Subtasks   

For $\textbf{40%}$ of the test cases, $1\leq p_i<2^7$  
For $\textbf{60%}$ of the test cases, $1\leq p_i<2^{17}$

Output Format

For each game, print W on a new line if John will win; otherwise, print L instead.

Sample Input 0
2
2
1 2
2
2 2

Sample Output 0
W
L

Explanation 0

John and Kate play the following $g=2$ games:

We have two piles, $p_0=1$ and $p_1=2$. John removes $1$ item from $p_1$, so $p_1=2-1=1$. Now that there is only $1$ item in each pile, gameplay can proceed in either of the following ways:

Kate removes the last object from one pile, then John removes the last object from the other pile.
Kate uses a Zero-Move on one of the piles, and John uses a Zero-Move on the other pile. Next, Kate must take the last object from one pile, at which point John removes the last object from the other pile.          

Because John always wins in either scenario, we print W on a new line.

John cannot win this game because the two piles are of equal size and Kate has an opportunity to counter any move he makes by performing the same action. Consider the following scenarios:

If John uses a Zero-Move on one pile, Kate can use a Zero-Move on the other pile (meaning the piles still have the same configuration after both players move).
If John removes one element from a pile, Kate can remove one element from the other pile so that both remaining piles contain one element when John takes his next turn. He would then be forced to empty one of the piles, leaving Kate to make the winning move by emptying the last pile.
If John removes both elements from one of the piles, Kate can remove both elements from the other pile and win the game.      

Because John always loses this game, we print L on a new line.

Difficulty: MEDIUM
Tags: Game theory

Starter code:

Solutions:
from itertools import *
from operator import *
from functools import *
for _ in range(int(input())):
	input()
	print('W' if reduce(xor, [x + 1 if x & 1 else x - 1 for x in map(int, input().split())], 0) else 'L')


import sys
import functools
import operator
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	nimbers = [0 if n == 0 else n - 1 if n % 2 == 0 else n + 1 for n in p]
	xor = functools.reduce(operator.xor, nimbers)
	if xor == 0:
		print('L')
	else:
		print('W')


import sys

def f(x):
	return x + 1 if x % 2 == 1 else x - 1
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	xor = 0
	for x in p:
		xor ^= f(x)
	print('L' if xor == 0 else 'W')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	res = 0
	for el in p:
		gx = el - 1 if el % 2 == 0 else el + 1
		if res == 0:
			res = gx
		else:
			res = res ^ gx
	john = res != 0
	print('W' if john else 'L')


import sys

def sp_value(x):
	if x % 2 == 1:
		return x + 1
	return x - 1
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	total = 0
	for x in p:
		total ^= sp_value(x)
	if total == 0:
		print('L')
	else:
		print('W')


from functools import reduce
g = int(input())
for i in range(g):
	n = int(input())
	l = [int(i) + 1 if int(i) % 2 == 1 else int(i) - 1 for i in input().split()]
	temp = reduce(lambda x, y: x ^ y, l)
	if temp == 0:
		print('L')
	else:
		print('W')


def solve(P):
	total = 0
	for p in P:
		total ^= p + 2 * (p % 2) - 1
	return total > 0
g = int(input())
for _ in range(g):
	n = int(input())
	P = list(map(int, input().split()))
	if solve(P):
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	xor = 0
	for size in p:
		if size % 2 == 0:
			xor ^= size - 1
		else:
			xor ^= size + 1
	if xor == 0:
		print('L')
	else:
		print('W')


import sys
import functools

def grundy(n):
	if n % 2 == 1:
		return n + 1
	else:
		return n - 1
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	result = functools.reduce(lambda x, y: x ^ y, map(grundy, p))
	if result == 0:
		print('L')
	else:
		print('W')


def cgrundy(n):
	if n >= 0:
		return n
	n = -n
	return n + (2 * (n & 1) - 1)
g = int(input())
for _ in range(g):
	n = int(input())
	P = map(int, input().split())
	res = 0
	for e in P:
		res ^= cgrundy(-e)
	print('W' if res != 0 else 'L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	result = 0
	for a in p:
		if a % 2 == 0:
			a = a - 1
		else:
			a = a + 1
		result ^= a
	if result == 0:
		print('L')
	else:
		print('W')


from functools import reduce
g = int(input())
for _ in range(g):
	n = int(input())
	heaps = [int(i) for i in input().split()]
	grundy = [i - 1 if i % 2 == 0 else i + 1 for i in heaps]
	nimsum = reduce(lambda x, y: x ^ y, grundy)
	if nimsum == 0:
		print('L')
	else:
		print('W')


import sys

def get_one_pile_sg(p):
	if p % 2 == 0:
		return p - 1
	else:
		return p + 1

def get_nim(ps):
	sgs = [get_one_pile_sg(p) for p in ps]
	cur = 0
	for sg in sgs:
		cur ^= sg
	return cur
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	ps = [int(p_temp) for p_temp in input().strip().split(' ')]
	nim = get_nim(ps)
	if nim != 0:
		print('W')
	else:
		print('L')


import sys

def get_grundy_number(n):
	if n == 0:
		return 0
	elif n % 2 == 0:
		return n - 1
	elif n % 2 == 1:
		return n + 1
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	result = 0
	for i in p:
		result ^= get_grundy_number(i)
	if result == 0:
		print('L')
	else:
		print('W')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	nim_sum = 0
	for pi in p:
		if pi % 2 == 0:
			gi = pi - 1
		else:
			gi = pi + 1
		nim_sum = nim_sum ^ gi
	if nim_sum == 0:
		print('L')
	else:
		print('W')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	grundy = 0
	for i in p:
		grundy ^= i + 1 if i & 1 else i - 1
	is_win = grundy != 0
	print('W' if is_win else 'L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	nim = 0
	for i in p:
		if i % 2 == 0:
			nim = nim ^ i - 1
		else:
			nim = nim ^ i + 1
	if nim != 0:
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	for i in range(len(p)):
		if p[i] % 2 == 0:
			p[i] = p[i] - 1
		else:
			p[i] = p[i] + 1
	s = 0
	for pe in p:
		s = s ^ pe
	if s == 0:
		print('L')
	else:
		print('W')


import sys

def G(n):
	if n > 5:
		if n % 2 == 0:
			return n - 1
		else:
			return n + 1
	else:
		return [0, 2, 1, 4, 3, 6][n]
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	Start = 0
	for i in p:
		Start = Start ^ G(i)
	if Start == 0:
		print('L')
	else:
		print('W')


import sys

def nim_solver(heaps):
	x = 0
	for h in heaps:
		if h % 2 == 0:
			h = h - 1
		else:
			h = h + 1
		x = x ^ h
	if x == 0:
		return False
	return True
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	if nim_solver(p):
		print('W')
	else:
		print('L')


g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	a = 0
	for x in p:
		a ^= x + 1 if x % 2 == 1 else x - 1
	print('L' if a == 0 else 'W')


import sys

def win_or_not(num, piles):
	grundy = 0
	for stone in piles:
		if stone % 2 == 0:
			grundy ^= stone - 1
		else:
			grundy ^= stone + 1
	print('L') if grundy == 0 else print('W')
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	win_or_not(n, p)


from functools import reduce
import operator

def first_wins(piles):
	return 0 != reduce(operator.xor, piles)

def g_number(n):
	if n % 2 == 0:
		return n - 1
	else:
		return n + 1
for _ in range(int(input().strip())):
	input()
	p = list(map(g_number, map(int, input().strip().split(' '))))
	print('W' if first_wins(p) else 'L')


g = int(input())
for _ in range(g):
	n = int(input())
	piles = list(map(int, input().split()))
	total = 0
	for p in piles:
		if p & 1:
			total ^= p + 1
		else:
			total ^= p - 1
	print('W' if total else 'L')


def solve(a):
	xor = 0
	for x in a:
		xor ^= (x - 1 ^ 1) + 1
	return 'W' if xor else 'L'

def test():
	assert solve([1, 2]) == 'W'
	assert solve([2, 2]) == 'L'

def read_ints():
	return list(map(int, input().split()))
test()
for _ in range(int(input())):
	input()
	print(solve(read_ints()))


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	res = 0
	for val in p:
		if val % 2 == 0:
			val -= 1
		else:
			val += 1
		res ^= val
	if res != 0:
		print('W')
	else:
		print('L')


import sys

def firstPlayerWins(rows):
	if not rows:
		return True
	temp = rows[0]
	for x in rows[1:]:
		temp = temp ^ x
	return temp != 0
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	newp = []
	for x in p:
		if x % 2 == 0:
			newp.append(x - 1)
		else:
			newp.append(x + 1)
	print('W' if firstPlayerWins(newp) else 'L')


import sys
q = int(input().strip())
for a0 in range(q):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	g = []
	for x in p:
		if x % 2 == 0:
			g.append(x - 1)
		else:
			g.append(x + 1)
	sum = 0
	for x in g:
		sum = sum ^ x
	if sum > 0:
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	res = 0
	for val in p:
		if val % 2 == 1:
			res ^= val + 1
		else:
			res ^= val - 1
	if res == 0:
		print('L')
	else:
		print('W')


from functools import reduce
g = int(input().strip())
for _ in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	q = []
	for x in p:
		if x & 1:
			q.append(x + 1)
		else:
			q.append(x - 1)
	nimsum = reduce(lambda a, b: a ^ b, q, 0)
	if nimsum == 0:
		print('L')
	else:
		print('W')


import sys

def nimber(p):
	value = 0
	for v in p:
		value ^= v - 1 if v % 2 == 0 else v + 1
	return value

def calculateMex(s):
	mex = 0
	while mex in s:
		mex += 1
	return mex

def calculateGrundy(n, hasZeroMove):
	if n == 0:
		return 0
	s = set()
	for i in range(0, n + 1 if hasZeroMove else n):
		s.add(calculateGrundy(i, i != n and hasZeroMove))
	return calculateMex(s)
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	val = nimber(p)
	doesWin = val != 0
	print('W' if doesWin else 'L')


import sys

def zero_nim_winner(init_piles):
	grundy = 0
	for p in init_piles:
		if p > 0:
			if p % 2 == 1:
				grundy = grundy ^ p + 1
			else:
				grundy = grundy ^ p - 1
	if grundy == 0:
		return 'L'
	else:
		return 'W'
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	print(zero_nim_winner(p))


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) + 1 if int(p_temp) % 2 == 1 else int(p_temp) - 1 for p_temp in input().strip().split(' ')]
	temp = p[0]
	for i in range(1, n):
		temp = temp ^ p[i]
	if temp == 0:
		print('L')
	else:
		print('W')


import sys

def grundy(s):
	if s == 0:
		return 0
	elif s % 2 == 0:
		return s - 1
	else:
		return s + 1

def nim_zero_wins(p):
	p = [grundy(s) for s in p]
	nimsum = p[0]
	for a in p[1:]:
		nimsum ^= a
	return nimsum != 0
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	print('W' if nim_zero_wins(p) else 'L')


import sys

def xorAll(p_list):
	xor_value = 0
	for p in p_list:
		xor_value = xor_value ^ p
	return xor_value
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	grundy = [x + 1 if x % 2 == 1 else x - 1 for x in p]
	grundy_sum = xorAll(grundy)
	if grundy_sum != 0:
		print('W')
	else:
		print('L')


import sys

def xorValues(p_list):
	xorVal = 0
	for p in p_list:
		xorVal = xorVal ^ p
	return xorVal
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	nimber = [x + 1 if x % 2 == 1 else x - 1 for x in p]
	nimber_sum = xorValues(nimber)
	if nimber_sum != 0:
		print('W')
	else:
		print('L')


from functools import reduce
import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	grundy = []
	for x in p:
		if x % 2 == 0:
			grundy.append(x - 1)
		else:
			grundy.append(x + 1)
	res = 0
	for x in grundy:
		res ^= x
	print(('W', 'L')[res == 0])


import sys
g = int(input())
for _ in range(g):
	n = int(input())
	piles = list(map(int, input().split()))
	xored = 0
	for pile in piles:
		xored ^= pile + 1 if pile % 2 == 1 else pile - 1
	print('L' if xored == 0 else 'W')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


from functools import reduce
from operator import xor

def fiddle(x):
	return (x - 1 ^ 1) + 1 if x else 0
g = int(input())
for _ in range(g):
	input()
	p = tuple((int(s) for s in input().split()))
	print('L' if reduce(xor, (fiddle(pi) for pi in p)) == 0 else 'W')


for _ in range(int(input().strip())):
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	s = 0
	for i in a:
		if i % 2 == 0:
			s ^= i - 1
		else:
			s ^= i + 1
	if s > 0:
		print('W')
	else:
		print('L')


from operator import *
from functools import *
for _ in range(int(input())):
	input()
	print('W' if reduce(xor, [x + 1 if x & 1 else x - 1 for x in map(int, input().split())], 0) else 'L')


import sys
for _ in range(int(input())):
	input()
	nimsum = 0
	for i in (int(x) for x in input().split()):
		nimsum ^= (i - 1 ^ 1) + 1
	print('W' if nimsum else 'L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	s = 0
	for i in p:
		s ^= (i - 1 ^ 1) + 1
	print('W' if s else 'L')


import sys
grundy = {}
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	k = 0
	for i in range(n):
		if p[i] % 2 == 0:
			k = k ^ p[i] - 1
		else:
			k = k ^ p[i] + 1
	if k != 0:
		print('W')
	else:
		print('L')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


for _ in range(int(input())):
	input()
	x = 0
	for i in map(int, input().split()):
		x ^= 1 + (i - 1 ^ 1)
	print('W' if x else 'L')


from operator import xor
from functools import reduce

def grundy(x):
	if x < BIT:
		return x
	elif x == BIT:
		return 0
	elif x % 2:
		return x - BIT + 1
	else:
		return x - BIT - 1
BIT = 1 << 30
for _ in range(int(input())):
	input()
	print('W' if reduce(xor, (grundy(int(x) | BIT) for x in input().split())) else 'L')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	sum1 = int(0)
	flag = int(0)
	for i in p:
		if i % 2 == 1:
			sum1 ^= i + 1
		else:
			sum1 ^= i - 1
	if sum1 == 0:
		print('L')
	else:
		print('W')


from functools import reduce
for _ in range(int(input())):
	__ = input()
	xs = list(map(int, input().split()))
	xs = list(map(lambda x: x + 1 if x % 2 else x - 1, xs))
	xsum = reduce(lambda x, y: x ^ y, xs, 0)
	print('W' if xsum else 'L')


def solve(P):
	s = 0
	for p in P:
		s ^= 0 if p == 0 else p - 1 + 2 * (p % 2)
	return s > 0
T = int(input())
for _ in range(T):
	N = int(input())
	P = list(map(int, input().split()))
	print('W' if solve(P) else 'L')


import sys

def nim_sum(s):
	score = 0
	for i in s:
		score ^= i
	return score
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) - 1 + int(p_temp) % 2 * 2 for p_temp in input().strip().split(' ')]
	score = nim_sum(p)
	if score != 0:
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	res = 0
	for i in p:
		if i % 2 == 0:
			res ^= i - 1
		else:
			res ^= i + 1
	if res == 0:
		print('L')
	else:
		print('W')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


import sys

def find_winner(nb_column, column_sizes):
	if nb_column == 1:
		print('W')
	result = 0
	for (index, column) in enumerate(column_sizes):
		if index == 0:
			if column % 2 == 0:
				result = column - 1
			else:
				result = column + 1
		elif column % 2 == 0:
			result = result ^ column - 1
		else:
			result = result ^ column + 1
	if result != 0:
		print('W')
	else:
		print('L')
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	find_winner(n, p)


import sys
grundy = [0, 2]
for n in range(2, 100):
	s = set()
	for i in range(n):
		s.add(grundy[i])
	m = 0
	while m in s:
		m += 1
	if m == n:
		m += 1
	grundy.append(m)
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	grund = 0
	for j in p:
		if j == 0:
			gr = 0
		elif j % 2 == 0:
			gr = j - 1
		else:
			gr = j + 1
		grund ^= gr
	print('W' if grund else 'L')


for _ in range(int(input())):
	input()
	nimsum = 0
	for i in (int(x) for x in input().split()):
		nimsum ^= (i - 1 ^ 1) + 1
	print('W' if nimsum else 'L')


test_case = int(input())
for temp_test_case in range(test_case):
	n = int(input())
	s = input()
	a = [int(elem) for elem in s.split()]
	x = 0
	for i in a:
		if i == 0:
			continue
		if i % 2 == 0:
			x = x ^ i - 1
		else:
			x = x ^ i + 1
	if x != 0:
		print('W')
	else:
		print('L')


g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	c1 = 0
	for i in p:
		if i % 2 == 0:
			c1 ^= i - 1
		else:
			c1 ^= i + 1
	if c1 == 0:
		print('L')
	else:
		print('W')
given = '\n10\n10\n56 72 69 26 18 25 64 77 64 105\n10\n45 1 42 40 52 13 28 28 55 40\n10\n38 76 67 30 65 45 63 36 54 33\n10\n61 55 53 38 73 77 53 69 12 105\n10\n65 13 71 25 16 3 52 43 9 33\n10\n4 34 14 68 78 76 55 3 60 63\n10\n66 12 53 10 41 25 78 52 54 13\n10\n16 76 39 32 30 42 26 38 57 73\n10\n10 72 12 7 19 18 42 30 57 48\n10\n21 28 57 61 53 7 64 58 21 5\n'
expect = '\nL\nL\nW\nL\nW\nW\nL\nW\nW\nW\n\n'
actual = '\nL\nW\nW\nW\nW\nW\nL\nW\nW\nW\n'


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


g = int(input())
for _ in range(g):
	n = int(input())
	s = [a - 1 if a % 2 == 0 else a + 1 for a in map(int, input().split())]
	x = 0
	for a in s:
		x ^= a
	print('W' if x else 'L')


from collections import defaultdict
from functools import reduce
from operator import xor

def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		piles = list(map(int, input().split()))
		piles = [p + 1 if p % 2 == 1 else p - 1 for p in piles]
		print('W' if reduce(xor, piles) != 0 else 'L')
main()


import sys
for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	x = 0
	for i in range(n):
		x ^= p[i] - 1 if p[i] % 2 == 0 else p[i] + 1
	print('L' if x == 0 else 'W')


from functools import reduce
from operator import xor
for _ in range(int(input().strip())):
	input()
	print('W' if reduce(xor, (n + 1 if n % 2 else n - 1 for n in map(int, input().strip().split(' ')))) else 'L')


def parseInput(f):
	return [f(x) for x in input().split()]
t = int(input())
for _ in range(t):
	n = int(input())
	arr = parseInput(int)
	answer = 0
	for x in arr:
		if x % 2:
			answer ^= x + 1
		else:
			answer ^= x - 1
	if answer:
		print('W')
	else:
		print('L')


import sys
for _ in range(int(input())):
	input()
	nimsum = 0
	for i in (int(x) for x in input().strip().split(' ')):
		nimsum ^= (i - 1 ^ 1) + 1
	print('W' if nimsum else 'L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	a = []
	for i in range(n):
		if p[i] == 0:
			a.append(0)
		elif p[i] % 2 == 0:
			a.append(p[i] - 1)
		else:
			a.append(p[i] + 1)
	ans = a[0]
	for i in range(1, n):
		ans = ans ^ a[i]
	if ans == 0:
		print('L')
	else:
		print('W')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = list(map(lambda n: n - 1 if n % 2 == 0 else n + 1, p))
	res = 0
	for n in p:
		res ^= n
	print('W' if res else 'L')


for _ in range(int(input())):
	(s, n) = (0, input())
	for x in input().split(' '):
		xi = int(x)
		s ^= xi + 1 if xi & 1 else xi - 1
	print('W' if s else 'L')


t = int(input())
for i in range(t):
	n = int(input())
	L = list(map(int, input().split(' ')))
	s = 0
	for i in range(n):
		if L[i] % 2 == 0:
			s = s ^ L[i] - 1
		else:
			s = s ^ L[i] + 1
	if s != 0:
		print('W')
	else:
		print('L')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from time import time

def nimber(h):
	if h == 0:
		return 0
	if h % 2 == 0:
		return h - 1
	return h + 1

def solve(hh):
	rval = 0
	for h in hh:
		rval ^= nimber(h)
	return rval > 0
tm = time()
t = int(input())
for _ in range(t):
	_ = int(input())
	hh = list(map(int, input().split()))
	if solve(hh):
		print('W')
	else:
		print('L')
print('time elapsed: %s' % (time() - tm,), file=sys.stderr)


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


from operator import xor
from functools import reduce

def win(p):
	return reduce(xor, (k - 1 + 2 * (k & 1) for k in p))
for _ in range(int(input())):
	input()
	print('W' if win(map(int, input().split())) else 'L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


for game in range(int(input())):
	n = int(input())
	nim_value = 0
	for pile in map(int, input().split()):
		if pile % 2 == 0:
			nim_value ^= pile - 1
		else:
			nim_value ^= pile + 1
	print(['W', 'L'][nim_value == 0])


import sys

def sp_value(x):
	if x % 2 == 1:
		return x + 1
	return x - 1
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	total = 0
	for x in p:
		total ^= sp_value(x)
	if total == 0:
		print('L')
	else:
		print('W')


for t_itr in range(int(input())):
	res = 0
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(n):
		if arr[i] % 2 == 1:
			x = arr[i] + 1
		else:
			x = arr[i] - 1
		res ^= x
	if res:
		print('W')
	else:
		print('L')


for t in range(int(input())):
	input()
	y = 0
	for z in input().split():
		x = int(z)
		if x % 2:
			x += 1
		else:
			x -= 1
		y ^= x
	if y:
		print('W')
	else:
		print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')


import sys
from functools import reduce
g = int(input().strip())
for a0 in range(g):
	n = int(input().strip())
	p = [int(p_temp) for p_temp in input().strip().split(' ')]
	p = [pt + 1 if pt % 2 == 1 else pt - 1 for pt in p]
	nimsum = reduce(lambda x, y: x ^ y, p)
	won = False if nimsum == 0 else True
	print('W') if won else print('L')