Middle digits P90755


Statement
 

pdf   zip

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.

Public test cases
  • Input

    8
    7 7 7 7 0 7 7 7 7 7 7 7 7 7 7 7
    

    Output

    B
    
  • Input

    3
    3 134 78345 333 6543456 999939999
    

    Output

    =
    
  • Input

    2
    98789 77 111 7
    

    Output

    A
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C++