P16264 [Lanqiao Cup 2026 NOI Qualifier Python B Group] Odd-Even Game

Description

Xiao Lan and Xiao Qiao are playing a game based on a sequence. At the beginning, a sequence of length $N$, $W_1, W_2, \dots, W_N$, is given. Every element in the sequence is a positive odd integer. Xiao Lan moves first, and they take turns to make moves. In each move, the current player needs to choose an element $W_i$ in the sequence that is strictly greater than $0$, and replace it with a non-negative integer $W_i'$ that is strictly smaller than it (that is, $0 \leq W_i' < W_i$). This replacement must strictly satisfy the following parity constraints: 1. If the chosen $W_i$ is odd, then it must be replaced with $W_i - 1$. 2. If the chosen $W_i$ is even, then the new number $W_i'$ must also be even. When it is a player's turn, if they cannot make any legal replacement, then they lose the game and the other player wins. Assume both Xiao Lan and Xiao Qiao are extremely smart and always use the optimal strategy. Determine who will win this game in the end.

Input Format

The first line contains an integer $T$, indicating the number of test cases. Then $T$ test cases follow. For each test case: - The first line contains an integer $N$, indicating the length of the sequence. - The second line contains $N$ positive odd integers $W_1, W_2, \dots, W_N$, separated by spaces.

Output Format

For each test case, output one line. If Xiao Lan wins, output `L`; if Xiao Qiao wins, output `Q`.

Explanation/Hint

### Constraints For all testdata, $1 \leq T \leq 10^3$, $1 \leq N \leq 10^5$, $1 \leq W_i \leq 10^9$. It is guaranteed that the sum of $N$ over all test cases does not exceed $2 \times 10^5$, and it is guaranteed that all $W_i$ in the initial input are odd. Translated by ChatGPT 5