Under construction

Still being built. Things may change

Box Splitting Game

Time limit2sMemory limit512 MB

Summary
Decide whether the first or second player wins the two-box stone-splitting game from starting counts N and M.
Level

Medium4 of 10

Topics
Game theory, Dynamic programming
Solved
No attempts yet

Problem

The box splitting game is played with two boxes.

At the start one box holds NN stones and the other holds MM stones. Two players take turns.

On your turn you choose one box and empty it completely. You then take the stones sitting in the other box and put them into the two boxes. Each of the two boxes must hold at least 1 stone afterwards.

The player who leaves exactly 1 stone in each box wins the game.

Given NN and MM, write a program that finds the winner when both players play the game perfectly.

Input

The first line contains NN and MM, separated by a space. (1≤N,M≤1001 \le N, M \le 100, and NN and MM are never both 1.)

Output

Print A if the player who starts the game wins, and B if the player who moves second wins.

Examples4

  1. Example 1

    Input
    1 2
    
    Expected output
    A
    
  2. Example 2

    Input
    1 3
    
    Expected output
    B
    
  3. Example 3

    Input
    2 2
    
    Expected output
    A
    
  4. Example 4

    Input
    3 3
    
    Expected output
    B