LCC '21 Contest 3 S4 - Nim-metry

View as PDF

Points: 12 (partial)
Time limit: 3.0s
Memory limit: 128M

Problem types

Amelia and Bedelia are competing in the game of Nim. Nim is a game in which there are piles of stones in which the th pile contains stones. On a player's turn, they may remove any positive number of stones, so long as all stones that player removes come from the same pile. The player who cannot move first loses.

However, since Amelia and Bedelia are both perfect logicians, they each figure out the solution to Nim fairly quickly and now they do not think it is very fun anymore. To make it more challenging, they introduce the following rule: After a player has moved, if the board is not symmetric, then the player who just moved loses immediately. The board is symmetric if the first nonempty pile has the same number of stones as the last non-empty pile, the second has the same number of stones as the second last, and so on. Note, empty piles are treated as if they do not exist. Just like normal Nim, if a player takes the last stone, they win.

Amelia and Bedelia plan to play games to determine who is the superior player. In every game, Amelia will make the first move. If both players play optimally, who wins each game?

Input Specification

The first line contains a single integer , the number of missions per test case,

The inputs for the games follow.

The first line of each game input contains a single integers, ,

The next line will contain integers, representing the size of each pile from left to right,

Output Specification

For each game, output the winner of the game, either Amelia or Bedelia

Sample Input

2
3
1 2 3
1
1

Sample Output

Bedelia
Amelia