CF1673A.Subtle Substring Subtraction

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Subtle Substring Subtraction

Alice and Bob are playing a game with strings. There will be tt rounds in the game. In each round, there will be a string ss consisting of lowercase English letters.

Alice moves first and both the players take alternate turns. Alice is allowed to remove any substring of even length (possibly empty) and Bob is allowed to remove any substring of odd length from ss.

More formally, if there was a string s=s1s2sks = s_1s_2 \ldots s_k the player can choose a substring slsl+1sr1srs_ls_{l+1} \ldots s_{r-1}s_r with length of corresponding parity and remove it. After that the string will become s=s1sl1sr+1sks = s_1 \ldots s_{l-1}s_{r+1} \ldots s_k.

After the string becomes empty, the round ends and each player calculates his/her score for this round. The score of a player is the sum of values of all characters removed by him/her. The value of a is 11, the value of b is 22, the value of c is 33, \ldots, and the value of z is 2626. The player with higher score wins the round. For each round, determine the winner and the difference between winner's and loser's scores. Assume that both players play optimally to maximize their score. It can be proved that a draw is impossible.

Input

The first line of input contains a single integer tt (1t51041\leq t\leq 5\cdot 10^4) denoting the number of rounds.

Each of the next tt lines contain a single string ss (1s21051\leq |s|\leq 2\cdot 10^5) consisting of lowercase English letters, denoting the string used for the round. Here s|s| denotes the length of the string ss.

It is guaranteed that the sum of s|s| over all rounds does not exceed 21052\cdot 10^5.

Output

For each round, print a single line containing a string and an integer. If Alice wins the round, the string must be "Alice". If Bob wins the round, the string must be "Bob". The integer must be the difference between their scores assuming both players play optimally.

Note

For the first round, "aba"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{ab}}}\texttt{a"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{"". Alice's total score is 1+2=31+2=3. Bob's total score is 11.

For the second round, "abc"}\xrightarrow{\texttt{Alice}}\texttt{"a}{\color{red}{\texttt{bc}}}\texttt{"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{"". Alice's total score is 2+3=52+3=5. Bob's total score is 11.

For the third round, "cba"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{cb}}}\texttt{a"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{"". Alice's total score is 3+2=53+2=5. Bob's total score is 11.

For the fourth round, "n"}\xrightarrow{\texttt{Alice}}\texttt{"n"}\xrightarrow{} \texttt{"n"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{n}}}\texttt{"}\xrightarrow{}\texttt{"". Alice's total score is 00. Bob's total score is 1414.

For the fifth round, "codeforces"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{codeforces}}}\texttt{"}\xrightarrow{} \texttt{"". Alice's total score is 3+15+4+5+6+15+18+3+5+19=933+15+4+5+6+15+18+3+5+19=93. Bob's total score is 00.

Samples

5
aba
abc
cba
n
codeforces
Alice 2
Alice 4
Alice 4
Bob 14
Alice 93

在线编程 IDE

建议全屏模式获得最佳体验