Dominoes

Anna and Bernard play the following game: First, they invent five words
each. Later, and alternatively, Anna writes her first word, Bernard
writes his first word, Anna writes her second word, Bernard writes his
second word, and so on. The first to write a word that does not start
with the same character with which ends the previous word, loses. (The
first word, always Anna’s, can start with any character.) If after
writing the 10 words nobody loses, the game ends in a draw.

Write a program to decide who wins every game.

Input

Input begins with a natural number indicating the number of games.
Follow the 10 words of every game, in this order: the first word of
Anna, the first word of Bernard, the second word of Anna, etcetera.

Output

For each game, print a line with ‘A’, ‘B’, or ‘=’, depending on whether
Anna wins, Bernard wins, or it is a tie.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:44:01.988Z

© Jutge.org, 2006–2026.
https://jutge.org
