Coins
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Alice has 4 types of coins. The values of the 4 types of coins are 2, 3, 17, 19, respectively. Each kind of coin has an unlimited supply.

Bob also has 4 types of coins. The values of the 4 types of coins are 5, 7, 11, 13, respectively. Each kind of coin has an unlimited supply.

There are q queries. The j-th query is described as an integer number x. The answer to the query is the minimum number of coins that is necessary to obtain the value x using some subset of coins (Alice or Bob). If it is impossible to obtain the value, the answer to the j-th query is -1. If both of them can obtain the minimum number, output "both". In the other case, you should output either "A" if Alice can obtain the minimum number or "B" if Bob can obtain the minimum number

输入描述:

The first line of the input contains an integer q () --- the number of queries.

Each of the following n lines contains an integer x (), the value obtained.

输出描述:

For each query, print a single line according to the description above.

示例1

输入

复制
4
0
1
2
3

输出

复制
both
-1
A
A