本站作为LDUOnlineJudge的测试版本进行演示,官方网站请访问http://icpc.ldu.edu.cn
[Hidden]

1223. C. UCF Hold-em Poker


Description

Dr. Orooji's children, as if they don't spend/waste enough time on Nintendo, want to learn some card games. So, they asked Dr. O to teach them poker and Texas Hold-em poker. Since poker (and the Texas Hold-em version of it) is rather complicated, Dr. O decided to teach a simplified version of it. And, since you are programming for free today, why not use you guys to help Dr. O!

A poker hand consists of five cards. The possible hands we will consider for this problem, from worst to best, are as follows:

BUST: any five cards that do not form one of the following hands

TWO OF A KIND: any two cards which match in value plus three other cards

THREE OF A KIND: any three cards which match in value plus two other cards

FULL HOUSE: any THREE OF A KIND plus TWO OF A KIND of a different value

FOUR OF A KIND: any four cards which match in value plus one other card

In our simplified version of Texas Hold-em (called UCF Hold-em), you are given seven cards and want to determine the best hand among the five possibilities above. That is, if you were to choose five of the seven cards, what is the best poker hand you can make?

The Problem:

Given seven cards (chosen from a single valid playing deck of cards), you are to determine the best poker hand using five of the cards. You'll choose the cards that will result in the best possible hand from the above five possibilities.

Input

There will be multiple test cases. The first input line contains a positive integer n, indicating the number of data sets to be processed. The data sets will be on the following nn input lines, each set on a separate line. Each set contains seven characters, starting in column one (with no spaces anywhere). The characters will be from the string "23456789TJQKA", representing the 13 possible card values.

Output

At the beginning of each test case, output "UCF Hold-em #h: ", where hh is the hand number (starting from 1). Then, output the input hand, followed by the best possible hand (on the next line).

Leave a blank line after the output for each test case. Follow the format illustrated in Sample Output.

Samples

Input Copy
5
2645372
83A5A2A
29T9TT3
JQ3Q4QQ
8756324
Output
UCF Hold-em #1: 2645372
Best possible hand: TWO OF A KIND

UCF Hold-em #2: 83A5A2A
Best possible hand: THREE OF A KIND

UCF Hold-em #3: 29T9TT3
Best possible hand: FULL HOUSE

UCF Hold-em #4: JQ3Q4QQ
Best possible hand: FOUR OF A KIND

UCF Hold-em #5: 8756324
Best possible hand: BUST

Source

UCF Practice 2013
Problem Information

Time Limit: 1000MS (C/C++,Others×2)
Memory Limit: 256MB (C/C++,Others×2)
Special Judge: No
AC/Submit: 1 / 1
Tags:
Contests involved

1026. UCF 2013 Practice
My history solutions

You didn't submit any solution!
Submit your solution

Login Register