#P1728D. Letter Picking
Letter Picking
No submission language available for this problem.
Description
Alice and Bob are playing a game. Initially, they are given a non-empty string , consisting of lowercase Latin letters. The length of the string is even. Each player also has a string of their own, initially empty.
Alice starts, then they alternate moves. In one move, a player takes either the first or the last letter of the string , removes it from and prepends (adds to the beginning) it to their own string.
The game ends when the string becomes empty. The winner is the player with a lexicographically smaller string. If the players' strings are equal, then it's a draw.
A string is lexicographically smaller than a string if there exists such position that for all and .
What is the result of the game if both players play optimally (e. g. both players try to win; if they can't, then try to draw)?
The first line contains a single integer () — the number of testcases.
Each testcase consists of a single line — a non-empty string , consisting of lowercase Latin letters. The length of the string is even.
The total length of the strings over all testcases doesn't exceed .
For each testcase, print the result of the game if both players play optimally. If Alice wins, print "Alice". If Bob wins, print "Bob". If it's a draw, print "Draw".
Input
The first line contains a single integer () — the number of testcases.
Each testcase consists of a single line — a non-empty string , consisting of lowercase Latin letters. The length of the string is even.
The total length of the strings over all testcases doesn't exceed .
Output
For each testcase, print the result of the game if both players play optimally. If Alice wins, print "Alice". If Bob wins, print "Bob". If it's a draw, print "Draw".
Note
One of the possible games Alice and Bob can play in the first testcase:
- Alice picks the first letter in : "orces", "f", "";
- Bob picks the last letter in : "orce", "f", "s";
- Alice picks the last letter in : "orc", "ef", "s";
- Bob picks the first letter in : "rc", "ef", "os";
- Alice picks the last letter in : "r", "cef", "os";
- Bob picks the remaining letter in : "", "cef", "ros".
Alice wins because "cef" < "ros". Neither of the players follows any strategy in this particular example game, so it doesn't show that Alice wins if both play optimally.