Middle digits

Anna and Bernard play the following game: First, they invent n numbers
each. Later, and alternatively, Anna writes her first number, Bernard
writes his first number, Anna writes her second number, Bernard writes
his second number, and so on. The first to write a number such that its
middle digit is not the same as the middle digit of the previous number,
loses. (The first number, always Anna’s, may have any middle digit.) If
someone writes a number with an even number of digits, he or she loses
immedialty. If after writing the 2n numbers nobody loses, the game ends
in a draw.

Write a program to decide who wins a game.

Input

Input consists of a natural number n ≥ 1, followed by 2n natural numbers
a₁, b₁, …, a_(n), b_(n): a₁ is the first number of Anna, b₁ is the first
number of Bernard, a₂ is the second number of Anna, etcetera.

Output

Print ‘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-25T10:27:34.600Z

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