All submissions for this problem are available.Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap. The goal of the game is to be the player to remove the last object.
Trump has come to the White house after winning the presidential elections. However, Obama has one condition before allowing him to enter. Trump must beat Obama at nim. As Obama knows that he is too good at the game, he decides to take a handicap. He allows Meliana to join the game. Trump and Meliana's turns are always consecutive. If Trump or Meliana play the last move, then Trump gets to be the President otherwise, Obama gets to continue his presidency. As Obama is very good he always plays optimally. Is it possible for Trump to become the president of the United States?
Note: If Trump plays first then Meliana plays second and if Meliana plays first then Trump plays second. If Obama plays first then either Trump or Meliana can play second.
InputThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contsins a string S, the name of the player which gets to move first. S can be "Trump", "Meliana" or "Obama".
The second line contains a integer N denoting the number of heaps with which the game is played.
The third line contains N space-separated integers A1, A2, ..., AN denoting the sizes of the N heaps.
OutputFor each test case, output a single line containing either "Yes" or "No" (without quotes), denoting whether it is possible for Trump to win the game.
Input: 3 Obama 1 1 Meliana 3 1 1 1 Trump 2 4 4
Output: No No Yes
Example case 1.Obama will empty the only heap and win the game.
Example case 2.Melina has to empty one heap and then Trump has to empty another heap, leaving one heap for Obama which wins him the game.
Example case 3.Trump and Meliana can reduce both heaps to sizes 1 in their turns. Then obama has to empty one of the heaps, leaving the last heap for Trump to destroy.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions