E - Grand Tichu! |
Tichu is becoming one of the most popular cards games in Europe. Either if you meet for coffee or for beers with 3 more friends, do not forget to bring your Tichu deck!
The Tichu deck is similar to French deck (i.e., four sets of 13 cards --2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, and Ace--), but with four extra special cards: Dragon, Phoenix, Mah Jong, and Dogs.
Tichu special cards: Dragon, Phoenix, Mah Jong, and Dogs.
The four players, playing two against two, receive all cards in the deck. And the main goal of the game is to play all your cards before the other players (the rules about how to play the cards are not important to resolve the problem). A player does not receive the 14 cards at the same time, but when he receives the first 8 cards, he needs to predict if he will finish before the others and bet for it by saying "Grand Tichu!".
Our friend likes to say "Grand Tichu!" a lot, but he is not always finishing first. After some discussions with his teammate, he decided to declare "Grand Tichu!" only if the probability of getting at least one of this four combinations when all cards are dealt is higher than 0.25:
The program input consist of several lines, each one with a sequence of eight characters indicating the first 8 cards. We use '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', and 'A' for the normal cards and 'D' for the Dragon, 'P' for the Phoenix, 'M' for the Mah Jong, and 'd' for the Dogs. The input terminates with a line with the string 0.
For each 8-card case, your program must print "Grand Tichu!" if the probability of getting any of the selected combinations is higher than 0.25, or "...", otherwise.
D23468AA
D2P4688K
D23468KA
D2233889
PdM2345T
PdM234AA
0
Grand Tichu!
Grand Tichu!
Grand Tichu!
...
...
...