Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3044
Gongzhu II

Time Limit: 2 Seconds      Memory Limit: 65536 KB

AAA is potty about playing cards and gongzhu is one of his favorites. One day, he was playing gongzhu with his friends at home. suddenly, one of AAA's friends asked him: "do you always give the right score for everbody in the end of the round?" AAA said: "er...I can figure out the score for you soon, but it's really a hard problem for me to tell you whether the score is right..." AAA was so depressed because he couldn't solve such a problem in one of his favorite games! So now he turns to you, an execellent programmer, for help.To help you understand the rule of the game, AAA show the details below:

Gongzhu is played by 4 players and every player will get some points after each round(a round means each time the players give out all the cards in their hands), the winner is the one with the highest points.

1. To play the game we need a standard deck of 52 cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K of Clubs, Diamonds, Hearts and Spades).

2. We have some special cards:

  • "Pig": Spade Q
  • "Sheep": Diamond J
  • "Change": Club 10
  • "A": Heart A

3. We have some cards with points:

  • 0 points for Heart 2, 3, 4 each
  • -10 points for Heart 5, 6, 7, 8, 9, 10 each
  • -20 points for Heart J
  • -30 points for Heart Q
  • -40 points for Heart K
  • -50 points for Heart A
  • -100 points for a "Pig" card
  • +100 for a "Sheep" card
  • If you get a single "Change" card, you may get +50 points, otherwise you may have to double your total points got from the other cards with points

4. We also have a special rule called "sell":
"sell" means you want to tell the others you have some special cards and certainly the game will become more interesting because of you~~ Everytime a special card is "sold", the points will change accordingly:

  • "Pig" may be -200 if it is sold
  • "Sheep" may be -200 if it is sold
  • If "Change" is sold, you may get +100 if you only get one "change" card, otherwise you may have to multiply your total points got from the other cards with points by 4
  • If Heart A is sold, the points for it may be -100. In the same time, all the other cards in suit "Heart" will double its own points.

5. What is worse, you may get a punish if you get one special card that you sell at the beginning:

  • "Pig" may be -400
  • "Sheep" may be -400
  • You may still get +100 if you only get one "change" card, but if get some other cards with points, you may have to multiply your total points got from the other cards with points by 8
  • For Heart A, the points may be -200 if it is sold by you.But for other cards with suit "Heart", you may get the points as it is gotten by others.

6. Full_Red: If a player gets all the Hearts in a game, these 13 cards turn to 200 points if Heart A is not sold, and 400 points if Heart A is sold. If we get a full_red, we may ignore all the 1-5 rules about the cards in suit "Heart"(that means the special cards except Heart A will still be considered).

7. Full_All: If a player gets all the cards with points in a game, then he gets 800 points. If we get a full_red, we may ignore all the 1-6 rules.

Input

The first line of input is the number of test cases T, then T lines follow, each is a test case with two positive integers n(the n cards only contain the special cards and the cards in suit "heart") and p(the points AAA calculates).We can assume that 0 <= n <= 16 in each case.

Output

For each case, output a "yes" in a single line if the points AAA calculates might be right, and a "no" in a single line if it is impossible.

Sample Input

2
2 -30
1 150

Sample Output

yes
no

Author: HE, Xing
Source: ZOJ Monthly, September 2008
Submit    Status