Chomp is a two-player game played using a rectangular chocolate bar made up of smaller squares (cells). The players take turns choosing one cell and eating it together with those cells that are above it and to its right. (this is a low sugar chocolate bar). The bottom left cell is poisoned and whoever is forced to eat it loses. The following diagram shows a game during a sequence of moves:
A position in a 3-by-100 CHOMP game is described by the number p of squares in the bottom row, the number q of squares in the middle row, and the number r of squares in the top row with:
$$ 100 ≥ p ≥ q ≥ r ≥ 0 $$
Write a program that determines whether a given position is a winning or losing position. If it is a winning position, give the next square to eat.
The first line of input contains a single decimal integer P,(1 ≤ P ≤ 500), which is the number of datasets that follow. Each dataset should be processed identically and independently. Each dataset consists of a single line of input containing the dataset number K followed by the counts 100 ≥ p ≥ q ≥ r ≥ 0 of squares in the bottom row (p), middle row (q), and top row (r). respectively, separated by single spaces
4 1 3 3 3 2 3 1 0 3 3 2 0 4 97 64 35
For each dataset there is a single line of output. If the input position is a losing position, the output line consists of the dataset number K, followed by a single space, followed by the capital letter ‘L’. Otherwise the output line consists of the dataset number K, followed by the capital letter ‘W’, followed by the column numbder and row number of the square to eat which results in a losing position for opponent
1 W 2 2 2 W 3 1 3 L 4 W 51 1