Under construction

Still being built. Things may change

Allin

Time limit1sMemory limit1024 MB

Summary
Given your two hole cards and the three flop cards, decide whether you win the showdown against every possible opponent hand and every possible turn and river.
Level

Medium5 of 10

Topics
Brute force, Simulation, Implementation
Solved
No attempts yet

Problem

Texas hold 'em (also known as Texas holdem, hold 'em, and holdem) is one of the most popular variants of the card game of poker. Please read the following rules as they may be different from the regular rules. Two cards, known as hole cards, are dealt face-down to each player. Each player only knows his own hole cards. Then five community cards are dealt in three stages face-up. The stages consist of a series of three cards ("the flop"), later an additional single card ("the turn" or "fourth street"), and a final card ("the river" or "fifth street"). All players know the face-up cards that are already dealt. All cards are drawn from a standard 52-card deck. A standard 52-card deck comprises 1313 ranks in each of the four French suits: clubs (♣\clubsuit), diamonds (♢\diamondsuit), hearts (♡\heartsuit) and spades (♠\spadesuit). Each suit includes an Ace (A), a King (K), Queen (Q) and Jack (J), each depicted alongside a symbol of its suit, and numerals or pip cards from the Deuce (Two) to the Ten, with each card depicting that many symbols (pips) of its suit. No card can be drawn more than once.

Individual cards are ranked as follows (high-to-low): A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2. Each player seeks the best five-card poker hand from any combination of the seven cards: the five community cards and his two hole cards.

The following table shows the possible five-card poker hand types in increasing order of their values. Each type has a specific ordering of the five cards that is described below. The following part describes how to compare two hands, which is the same as the regular rule.

  • Highcard: Simple value of the card. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1>a2>a3>a4>a5a_1>a_2>a_3>a_4>a_5. (aia_i represents the rank of the ii-th card.)

  • Pair: Two cards with the same value. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1=a2a_1=a_2, a3>a4>a5a_3>a_4>a_5, a1≠a3a_1 \ne a_3, a1≠a4a_1 \ne a_4, a1≠a5a_1 \ne a_5.

  • Two pairs: Two times two cards with the same value. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1=a2a_1=a_2, a3=a4a_3=a_4, a1>a3a_1 > a_3, a1≠a5a_1 \ne a_5, a3≠a5a_3 \ne a_5.

  • Three of a kind: Three cards with the same value. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1=a2=a3a_1=a_2=a_3, a4>a5a_4 > a_5, a1≠a4a_1 \ne a_4, a1≠a5a_1 \ne a_5.

  • Straight: Sequence of 5 cards in increasing value. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that aia_i is exactly one rank above ai+1a_{i+1} for all 1≤i≤41\le i\le 4. Specially, if a5a_5 is Ace, a4a_4 can be 22. In this case, Ace is considered one rank below 2.

  • Flush: 5 cards of the same suit. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that all five cards have the same suit and a1>a2>a3>a4>a5a_1>a_2>a_3>a_4>a_5.

  • Full house: Combination of three of a kind and a pair. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1=a2=a3a_1=a_2=a_3, a4=a5a_4=a_5.

  • Four of a kind: Four cards of the same value. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1=a2=a3=a4a_1=a_2=a_3=a_4.

  • Straight flush: Straight of the same suit. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that all five cards have the same suit and aia_i is exactly one rank above ai+1a_{i+1} for all 1≤i≤41\le i\le 4. Specially, if a5a_5 is Ace, a4a_4 can be 22. In this case, Ace is considered one rank below 2.

  • Royal flush: Straight flush from Ten to Ace. The cards are ordered as a1a2a3a4a5a_1a_2a_3a_4a_5 such that a1,a2,a3,a4,a5a_1, a_2, a_3, a_4, a_5 are Ace, King, Queen, Jack, Ten of the same suit.

To compare two hands, first compare the types of the two hands. For example, if one hand is Four of a kind and the other is Full house, Four of a kind always wins.

If the types of two hands are the same, compare the ranks of the cards. Order the cards as described above, and compare them one by one. First compare the first card. If a hand's first card has a higher rank, it wins. If the first cards have the same rank, compare the second card, and so on. If the cards have the same rank in every position, no one wins. The suit of a card never matters. For example, ♣\clubsuit 5, ♢\diamondsuit 5, ♡\heartsuit 5, ♠\spadesuit 2, ♣\clubsuit 2 beats ♢\diamondsuit 3, ♠\spadesuit 3, ♡\heartsuit 3, ♢\diamondsuit A, ♡\heartsuit A. Both are Full house, so compare the ranks of the three-of-a-kind cards first.

Consider the case where the hole cards of Alice are ♣\clubsuit A, ♢\diamondsuit 4 and the hole cards of Bob are ♡\heartsuit 2, ♠\spadesuit 3. The community cards are ♠\spadesuit A, ♡\heartsuit 4, ♠\spadesuit 5, ♣\clubsuit Q, ♡\heartsuit Q. The best hand of Alice (five cards among her hole cards and the community cards) is ♣\clubsuit A, ♠\spadesuit A, ♣\clubsuit Q, ♡\heartsuit Q, ♠\spadesuit 5, which is Two pairs. The best hand of Bob is ♠\spadesuit 5, ♡\heartsuit 4, ♠\spadesuit 3, ♡\heartsuit 2, ♠\spadesuit A, which is Straight. Thus, Bob wins.

Players have betting options to check, call, raise, or fold. In this problem, we do not care about the meanings of these bets. Rounds of betting take place before the flop is dealt and after each subsequent deal. The player who has the best hand and has not folded by the end of all betting rounds wins all of the money bet for the hand, known as the pot. In certain situations, a "split-pot" or "tie" can occur when two players have hands of equivalent value. This is also called a "chop-pot". In this problem, we assume the two players never fold. So the player with the best five-card poker hand from any combination of the seven cards wins. If the two players have hands of equal value, no one wins.

To simplify the statement, we do not introduce the detailed rules here.

Daddy Dream is a world-famous Texas hold 'em player. As a strong challenger, Wolf Chicken wants to beat Daddy Dream. Wolf Chicken plays first after "the flop" (three cards are dealt face-up). Both players know the three face-up cards, and each player knows his own two hole cards. Wolf Chicken will choose to allin if and only if he will certainly win whatever the "the turn" and "the river" (the remaining two community cards that have not been revealed) and Daddy Dream's hole cards are. Otherwise, Wolf Chicken will choose to check.

Given Wolf Chicken's two hole cards and the three flop cards, help him determine whether he can allin.

Input

The first line contains a single integer TT (1≤T≤1000001\le T \le 100000) denoting the number of test cases.

For each test case, there is one line containing five strings h1,h2,c1,c2,c3h_1, h_2, c_1, c_2, c_3 separated by single spaces, denoting the first hole card, the second hole card, the first community card, the second community card and the third community card.

For each card, the first character of its string denotes its rank. Possible ranks are '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'. 'T' denotes 1010. The second character denotes its suit. 'C' denotes clubs, 'D' denotes diamonds, 'H' denotes hearts, and 'S' denotes spades.

It is guaranteed that each card appears at most once in one test case.

Output

For each test case, print one line. Print "allin" if Wolf Chicken will certainly win. Otherwise, print "check".

Examples1

  1. Example 1

    Input
    2
    AC KC QC JC TC
    AC TD 8S 5H 2C
    
    Expected output
    allin
    check