P10187 [USACO24FEB] Palindrome Game B

Description

Bessie and Elsie are playing a game with a pile of stones that initially contains $S$ stones ($1\le S

Input Format

The first line contains $T$, the number of test cases. The next $T$ lines describe the test cases, one line per test case. Each test case is specified by a single integer $S$.

Output Format

For each test case, output B if Bessie wins the game under optimal play starting with a pile of stones of size $S$, or E otherwise, on a new line.

Explanation/Hint

For the first test case, Bessie can remove all the stones on her first move, since $8$ is a palindrome, guaranteeing her win. For the second test case, $10$ is not a palindrome, so Bessie cannot remove all the stones on her first move. Regardless of how many stones Bessie removes on her first move, Elsie can always remove all remaining stones on her second move, guaranteeing her win. For the third test case, it can be proven that Bessie wins under optimal play. #### SCORING: - Inputs 2-4: $S