A No-Win Situation#538

A No-Win Situation

1 second
64 megabytes
Medium

Consider a simple variation of the card game Blackjack. In this game, a single player plays against the dealer. The game uses a standard deck of cards, where numbered cards are worth the number of points on the card for cards numbered to , points for the face cards (King, Queen, and Jack), and either or points for the Aces.

The dealer deals the first card in the deck to the player, the second to the dealer, the third to the player, and the fourth to the dealer. The player can continue to draw cards until their total is as close as possible to and they choose to stop, or until they go over . If the player goes over , they lose. Then, the dealer must draw cards until reaching or more points (with aces counting as when possible). If the dealer goes over , the dealer loses. If neither goes over , the winner is the one who comes as close as possible to . If the player and the dealer have the same total, the player wins.

For example, suppose the first cards in the deck are Queen, , , , and . In the initial deal, the player will receive Queen and (total ), and the dealer will receive and (total ). If the player does not draw a card, the dealer must draw (since their total is less than ) and will draw the , going over , so the player wins. But if the player draws a card (), their total becomes , so the player loses.

In some situations, it is impossible for the player to win. Consider the case when the cards in the deck are: , , , King, , . The player will be dealt and . The dealer will have and King. The table below illustrates what happens for each number of cards the player might draw:

No matter how many cards the player draws, the player cannot win.

In this problem, you have to analyze decks to determine if they lead to a situation in which the player cannot win.

Input

The input contains one or more decks. Each deck is represented by a string on its own line. Each deck will contain at least cards, where a card is either an integer , 2 \leq d \leq 9, representing a numbered card, or one of the letters , , , , or , representing Ace, King, Queen, Jack, or Ten, respectively. The letters will be uppercase. There will be no other characters on a line, in particular, no spaces. There will always be enough cards to try all valid draws. The end of input is denoted by the word JOKER alone on a line.

Output

Print a list of responses for the input decks, one per line. Print the word Yes if there is a way for the player to win by drawing some cards, and No if there is no way for the player to win. Print these words exactly as shown. Do not print any blank lines between the outputs.

Examples

Example 1

Loading
Loading