Poker Game: Decision
시간 제한8초메모리 제한1024 MB
열 장의 카드가 모두 공개된 상태에서 앨리스와 밥이 번갈아 커뮤니티 카드를 골라 다섯 장의 포커 패를 완성할 때, 최적 전략에서의 승자를 판정한다.
문제
Alice and Bob invent a new game based on Texas hold'em. Please read the following rules carefully as they are different from the usual rules. The background of this problem is exactly the same as problem E.
There are ranks, which are A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, and 2 from high to low. There are suits, which are S, H, C, and D. Every combination of a rank and a suit occurs exactly once, so there are () cards.
A hand is a set of five cards. Each hand has a rank. There are types of hands. Each type also has a rank. If two hands are of different types, the hand of the type with a higher rank always ranks higher. A hand can be represented as a sequence , where is the rank of the -th card and the order of the five cards depends on the type of the hand. If two hands are of the same type, the hand represented as the lexicographically larger sequence ranks higher: formally, if we find the smallest index such that of two hands are different, the hand with higher ranks higher. If the types and the sequences of two hands are equal, two hands have the same rank.
The types are given below, from lowest to highest rank. If a hand matches the patterns of multiple types, it belongs to the one with the highest rank.
- Highcard: Any five cards. The sequence satisfies .
- Pair: Two cards with the same rank. The sequence satisfies , .
- Two pairs: Two cards with the same rank and another two cards with the same rank. The sequence satisfies .
- Three of a kind: Three cards with the same rank. The sequence satisfies , .
- Straight: Five cards with five consecutive ranks. The sequence satisfies . Additionally,
A 2 3 4 5is a straight, andAis regarded as a rank lower than2in this case. HenceA 2 3 4 5is the straight with the lowest ranks. - Flush: Five cards with the same suit. The sequence satisfies .
- Full house: Three cards with the same rank and another two cards with the same rank. The sequence satisfies , .
- Four of a kind: Four cards with the same rank. The sequence satisfies .
- Straight flush: A straight with the same suit. The sequence satisfies . Additionally,
A 2 3 4 5with the same suit is a straight flush, andAis regarded as a rank lower than2in this case. HenceA 2 3 4 5with the same suit is the straight flush with the lowest ranks. - Royal flush: Straight flush with the ranks
T,J,Q,K, andA. Four different royal flushes are of the same rank.
Two cards are dealt to each of Alice and Bob. Instead of the regular rules, community cards are dealt. Two players take community cards one by one, in turn, until each player has five cards, completing a hand. Alice takes first. The player who has a hand with higher rank wins. If two hands have same rank, there is a draw. Note that all ten cards are shown to both, and they always choose the optimal strategy.
The above are the same in problem E. The task is the following.
Given the cards of Alice, the cards of Bob and the community cards, find the winner.
입력
There are multiple test cases. The first line of input contains an integer (), the number of test cases. For each test case:
The first line contains two strings and : Alice's initial cards.
The second line contains two strings and : Bob's initial cards.
The third line contains six strings , , , , , and : the community cards.
Each string is of length two. The first character is one of "A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2", which represents the rank of a card. The second character is one of "S", "H", "C", "D", which represents the suit of a card.
It is guaranteed that all given cards are pairwise distinct.
출력
For each test case:
Output the word "Alice" if Alice wins, "Bob" if Bob wins, or "Draw" if there is a draw.