Middle digits

Anna and Bernard play the following game: First, they invent nn 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 2n2n 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 n1n\ge 1, followed by 2n2n natural numbers a1,b1,,an,bna_1, b_1, \dots, a_n, b_n: a1a_1 is the first number of Anna, b1b_1 is the first number of Bernard, a2a_2 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