Statistics

Problem Statement for "GameWithTree"

Problem Statement

Little Petya likes rooted trees a lot. Recently he has received one as a gift from his mother. The only thing Petya likes more than rooted trees is playing with little Masha. The children painted each node of Petya's new tree either black or white. The tree is represented by the int[] parent. Let N denote the number of nodes in the tree. The nodes are numbered 0 through N-1. Node 0 is considered to be the root of the tree. Then for each i between 0 and N-2, inclusive, the tree contains an edge between nodes (i+1) and parent[i]. (Note that parent[i] may sometimes be greater than i+1.) The colors of nodes are given in the String color that consists of characters 'W' and 'B'. If the i-th character (0-based index) of color is 'W', then the i-th node is colored white, otherwise it's colored black.


The children decided to play a game with this tree. In the game Petya and Masha take alternating turns, Masha plays first. On his or her turn, the current player selects a white node, along with any subset of its descendants. (The subset can be arbitrary, possibly disconnected or even empty.) The player then toggles the color of all selected vertices: black nodes become white and vice versa. A player who can't make a turn loses the game. You goal is to determine who will be the winner assuming that both kids play optimally. Return "Masha" (without quotes) if Masha wins, otherwise return "Petya".

Definition

Class:
GameWithTree
Method:
winner
Parameters:
int[], String
Returns:
String
Method signature:
String winner(int[] parent, String color)
(be sure your method is public)

Notes

  • Node A is called a descendant of the node B if either B is a parent of A or a parent of A is descendant of the node B.

Constraints

  • parent will contain N-1 elements.
  • Each element of parent will be between 0 and N-1, inclusive.
  • color will contain N characters.
  • N will be between 2 and 50, inclusive.
  • Each character of color will be either 'B' or 'W'.
  • It's guaranteed that the graph described by parent is a rooted tree with root 0.

Examples

  1. {0}

    "WW"

    Returns: "Masha"

    As the root is white, Masha may select the root together with any subset of other vertices in the tree. The optimal strategy for her is to select and toggle both vertices.

  2. {0,0}

    "BWW"

    Returns: "Petya"

    Here the root is black. Masha must select and toggle exactly one of the leaves on her first turn. Then, Petya will select the other leaf and win the game.

  3. {0,1,2,3}

    "BBBBB"

    Returns: "Petya"

    In this test case there are no white nodes, so Masha can't even make the first move.

  4. {5,5,6,6,0,0}

    "BBWWBWW"

    Returns: "Petya"

    Here we have a black root that has two children with identical subtrees. Petya can mirror Masha's moves. This will guarantee him a victory.

  5. {5,5,6,6,0,0}

    "BWWBBBW"

    Returns: "Masha"

    One optimal strategy for Masha: In the first turn, Masha will select and toggle only the node 6. Thus, only two white nodes will remain, both of them will be leaves. After Petya toggles one of them, Masha will toggle the other one and win. (Note that there are also other winning strategies for Masha in this situation.)

  6. {18,33,39,19,42,26,24,1,14,18,7,14,1,22,8,27,40,0,23,30,4,26,29,13,14,29,29,30,18,1,32,8,23,6,18,4,35,1,18,1,36,35}

    "BWBBBBBBBBBBBWBBBBBBBBBWBBWBBBBBBBBBBBBBBBB"

    Returns: "Petya"

  7. {40,19,4,32,29,32,40,10,24,3,19,19,23,40,40,21,13,41,1,0,18,21,29,7,28,1,36,8,0,18,19,1,0,36,36,19,31,6,40,0,36,7}

    "BBBBWBWBBBWBBWBBBBBWBWBWBBBBWWBWWBBBWBBBBWB"

    Returns: "Masha"

  8. {15,0,13,10,16,23,23,20,27,1,0,20,23,2,13,25,26,15,4,0,10,13,0,16,13,13,11,14}

    "BBBWBBBBBWWBBBBBBWBWBWBBWWBBB"

    Returns: "Petya"

  9. {5,17,9,5,15,5,16,5,13,16,9,13,17,5,0,0,16,0,15,0}

    "BWWBWWBBWBBBWBBBWBWBW"

    Returns: "Masha"

  10. {20,8,16,23,17,0,19,0,0,19,27,19,0,18,11,18,1,0,18,6,20,21,14,27,12,2,14,19}

    "BBBWBBBBBWWBBWWBBBBBWBWBWBWBW"

    Returns: "Petya"

  11. {3,37,10,34,19,21,44,9,0,42,19,34,25,46,10,25,9,28,40,25,23,8,47,26,10,10,46,10,36,17,44,0,27,9,9,46,35,10,38,0,6,32,23,32,32,44,32,43}

    "BWBBBBBWBBWBBWBWBBWBWBWBWBBBWWWWWBBBBWBWWWBBBWBBB"

    Returns: "Masha"

  12. {0,5,35,37,20,10,25,41,0,41,0,41,0,18,1,11,29,40,35,0,39,38,25,17,19,30,8,21,13,8,6,27,0,21,15,37,41,13,0,11,19,1,3,29,19}

    "BBWBBBBBBWWBWBWBWBWBBBBBWWWBWWWWWWWBWWBBBBBWWW"

    Returns: "Petya"

  13. {17,36,7,40,29,28,40,37,16,13,24,9,11,19,28,17,24,4,24,7,16,14,30,0,13,40,37,45,4,24,26,24,19,0,17,40,43,28,45,0,22,16,7,38,0}

    "WBBBWBBBBWBWBWBBBBBBBBBBBBBBBBBBBWBBBBBBWBBWBB"

    Returns: "Masha"

  14. {0}

    "BB"

    Returns: "Petya"

  15. {16,23,6,26,12,26,5,22,26,0,19,13,36,19,26,19,22,3,30,16,28,13,36,25,26,23,5,30,0,26,28,36,22,26,26,0}

    "BWBWBBBBBBWBBWWBWWBBBBWWWWBWWWWBWBBBB"

    Returns: "Masha"

  16. {2,0}

    "BBB"

    Returns: "Petya"

  17. {3,3,0}

    "WWWB"

    Returns: "Masha"

  18. {0,0,1,3,3}

    "BBBBWW"

    Returns: "Petya"

  19. {6,0,6,6,2,0}

    "BWWBWWB"

    Returns: "Masha"

  20. {2,0,0}

    "BWBW"

    Returns: "Petya"

  21. {4,6,0,3,6,0,6}

    "BWWBWWWW"

    Returns: "Petya"

  22. {0,1}

    "BBB"

    Returns: "Petya"

  23. {0,1}

    "BBW"

    Returns: "Masha"

  24. {7,6,0,2,0,1,0}

    "BBBBBBBB"

    Returns: "Petya"

  25. {0,3,6,1,1,4,5}

    "BBBBWBBB"

    Returns: "Masha"

  26. {0,31,43,3,31,20,20,17,47,34,24,25,33,43,46,47,29,0,39,3,37,8,46,16,2,18,24,14,1,19,28,39,15,25,18,20,25,24,17,18,2,24,33,5,10,18,48,28,22}

    "BWWWWWWWBWBWBWBBBBBBBBBWBBWWBBBWWBWWWWWBWBWBWWBBWW"

    Returns: "Petya"

  27. {16,21,36,22,19,13,29,21,28,40,5,16,36,6,47,35,28,24,0,13,31,24,9,15,32,13,29,33,30,43,47,40,11,18,33,25,8,9,0,18,19,2,19,25,6,26,1,36,4}

    "WBBBBWBBBBBBBBBWWWWWBBBBWBBBBBBBWWBBBBBBWBBBBBBBBB"

    Returns: "Masha"

  28. {37,28,4,14,12,19,25,41,7,17,10,26,7,47,29,17,21,28,5,21,18,35,20,33,5,0,48,39,0,1,27,10,13,40,29,0,14,47,12,39,9,38,0,27,21,4,24,24,33}

    "BWBBWBBBBBBBBBWBBWBWWWBBWBBWWWBBBWBBBBWWBBBBBBBBBB"

    Returns: "Petya"

  29. {22,7,26,32,27,21,21,15,48,33,1,24,11,10,0,49,42,11,47,18,48,5,30,44,21,46,16,44,34,29,0,36,29,31,23,41,36,2,11,15,46,32,47,15,18,24,26,27,36}

    "BBWWBBWWBWBWWWWWBWBWWWWWBWWBWWWBWWWWBBWWBBWWBWBBWW"

    Returns: "Masha"

  30. {44,5,1,39,6,34,32,42,6,0,5,43,35,3,27,21,1,25,15,44,22,2,49,41,43,1,18,35,23,26,41,28,34,38,30,29,26,10,14,2,22,36,31,31,38,22,39,23,34}

    "BBBBBBBWWWBWWBBBWWBWBBBBWBBBBBBBWWBBBWBWWBBWBWWWWW"

    Returns: "Petya"

  31. {0,3,19,35,2,33,5,30,47,3,5,33,21,23,20,31,4,42,36,0,8,33,25,30,45,10,25,10,35,23,23,45,46,9,39,20,7,42,36,21,16,37,20,8,46,47,28,9,35}

    "WBBWBBWBWBBBBWBBBWBBBBWBBBBWWBBWBBWWBWBBWBBBWBWWWW"

    Returns: "Masha"

  32. {47,19,38,44,24,29,26,14,40,42,1,2,27,11,46,40,39,27,30,37,11,33,16,31,2,38,32,17,0,13,41,14,6,45,48,47,46,24,0,10,37,24,29,20,44,11,0,22,4}

    "BBBWBBBWWBBBWWWBBBWBBWWWBBWBBBBWWBBBBBBBBWWWWBBBWB"

    Returns: "Petya"

  33. {46,10,49,3,14,31,44,47,0,43,7,24,21,28,0,7,26,0,43,39,29,15,5,7,16,12,8,44,47,4,39,31,0,20,16,26,25,31,37,19,33,38,38,41,40,22,18,30,6}

    "BBBBWWWBWWWBWBWBWWBBWWBWWBWWWWWBWWWBWBWWWBBWWBWBBB"

    Returns: "Masha"

  34. {7,8,47,26,13,0,26,33,29,30,16,10,10,43,46,36,31,37,18,41,44,33,27,4,29,44,24,13,44,23,3,1,15,13,0,12,0,30,5,35,0,14,3,37,35,17,32,32,39}

    "BBWWBWWBWWBWWWBBBWWWWWWWBWBWWWWWBBWWWBWWWWWBBWBBBW"

    Returns: "Petya"

  35. {36,13,17,36,18,38,21,15,0,45,44,17,35,6,23,5,39,46,10,26,27,46,4,7,3,0,14,24,5,37,25,41,26,8,5,38,14,16,9,0,15,49,23,7,8,3,5,34,18}

    "WWBBBWBBWBWBWBBBWBWBWBWWWBWBWWWBBWWBBBBWBBBBBWWBWB"

    Returns: "Masha"

  36. {38,4,31,32,12,4,17,16,2,1,8,43,49,3,22,37,14,17,46,49,24,42,5,8,45,47,19,23,3,37,34,27,23,48,43,1,9,7,2,26,48,45,0,19,13,28,11,40,10}

    "BBBBBBWBBBBBWBBWBBWBWWWBWWBBBWWBBWBWWBBWBWBWWBBBBB"

    Returns: "Masha"

  37. {0,5,43,20,47,36,20,17,2,42,10,16,15,3,23,25,26,0,39,14,37,39,46,21,9,35,24,36,40,32,48,3,8,41,40,4,12,42,13,18,12,24,19,47,38,26,48,28,43}

    "BWBBBBWWBBBWBBBBBBBBBBWBBBBWBWWWBWWBBBBBBBBBWWBBBW"

    Returns: "Petya"

  38. {35,5,14,19,41,3,9,15,44,34,12,36,30,24,30,10,18,22,0,32,25,16,46,2,42,48,35,34,31,29,26,49,4,7,11,33,9,33,21,24,28,15,47,27,20,0,40,6,43}

    "BWWWWBWBBBWWWWBBBWBWWWWWBBBWWWBWBBBWWWWWWBBWWBWBWW"

    Returns: "Masha"

  39. {24,4,29,30,31,8,43,9,15,49,45,37,5,36,23,39,12,28,47,44,5,41,40,32,26,21,6,29,17,42,14,11,23,40,14,27,22,21,7,10,43,32,48,47,25,18,18,4,0}

    "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"

    Returns: "Petya"

  40. {33,15,39,3,0,49,34,35,48,35,43,34,5,16,25,47,45,38,48,13,30,41,36,6,28,13,16,4,6,45,27,33,40,26,24,9,18,21,46,23,39,25,9,12,7,1,2,37,14}

    "BBBBWWWWWBWWWBBWWWBWWBWBBWBWWWWWWWBWWBBBBBWBWBWBWB"

    Returns: "Masha"

  41. {5,42,27,15,30,0,43,31,39,12,3,13,2,16,5,46,10,48,21,34,8,25,32,0,37,6,35,29,38,26,7,8,45,23,47,11,47,17,36,30,43,23,9,48,36,12,44,15,22}

    "BBBBBBBBBBBBBBBBBBBBBBWBWBBBBBBBBWBBBBWBWBBBBWWBBW"

    Returns: "Petya"

  42. {6,0,44,35,48,15,31,13,37,46,19,36,29,19,3,37,23,21,25,36,49,3,11,17,34,2,8,47,18,26,17,16,42,30,24,1,27,10,45,30,26,32,9,10,12,33,22,21,35}

    "BBBWBWWWWBWBWBWBBBBBWWBWBBBBWBBBBWWBBBBWWWBWBBWBBW"

    Returns: "Masha"

  43. {38,42,44,14,11,2,9,46,5,40,49,36,17,32,39,24,1,19,20,41,14,4,29,7,18,8,39,19,16,48,22,43,9,13,0,26,26,10,25,27,37,3,23,22,15,6,45,44,0}

    "BBBBBBBBBBBBBWBBBBBBBBBBBBBBBBBBBBBBWBBBBBBBBWBBWB"

    Returns: "Petya"

  44. {48,44,17,15,41,16,28,30,14,44,8,25,12,5,19,24,47,43,42,11,8,24,39,2,32,14,49,4,0,3,46,36,18,1,25,39,20,49,0,26,12,26,6,28,46,37,34,27,18}

    "BWBBWWWBBBWWBBBBWBBWWBBBWWBWBBBBBWWWBWBBBBBWBWBBWW"

    Returns: "Masha"

  45. {23,13,15,37,34,47,25,26,18,44,3,9,10,0,2,2,12,11,23,17,1,0,41,17,4,20,28,34,33,26,48,15,7,21,41,8,36,13,48,11,22,24,9,31,5,25,37,45,27}

    "BBBBBBWWBBBBBBBBWBBBBBBBBBBBWBBBBBBBBBBBBBWBBBWBBB"

    Returns: "Petya"

  46. {9,45,12,0,47,19,30,6,37,7,33,8,17,40,16,20,9,25,4,2,11,3,13,30,46,46,17,40,12,21,5,2,15,10,48,31,34,28,21,44,37,23,8,5,18,22,23,15,16}

    "BWBBBBBWWBBWBWWWBBBWWBWWWWWWBBBWWBBWWBWWWWWWWBBBWW"

    Returns: "Masha"

  47. {25,19,49,0,18,45,48,32,11,31,6,10,7,17,36,0,21,2,37,21,35,9,13,20,33,25,44,19,12,37,34,46,43,39,29,27,38,9,27,14,13,1,4,1,23,45,12,14,18}

    "BBBBBWBBWBBBBBBBBBWBWBBBBBBBBBWBWBBBWBBBWWBBBBWWBW"

    Returns: "Petya"

  48. {10,48,31,14,20,2,14,15,33,44,8,35,4,45,27,26,16,1,41,3,24,15,18,18,30,24,17,0,37,8,46,11,25,0,38,34,36,5,32,12,9,46,45,7,40,29,21,36,35}

    "BBBWBWBBWWWWWBWBWBBWWWBWWBWWWWBBBWBBWBBBBBBBWWBWBB"

    Returns: "Masha"

  49. {28,37,10,8,46,4,47,33,26,43,44,14,31,39,40,39,14,19,35,12,12,29,35,41,3,49,40,9,32,42,9,6,45,0,15,34,43,5,36,22,7,45,38,4,1,21,25,11,41}

    "BBWBBBBBBBBBBWBBWWWWBBBWWBBWBBWWBBBWBBBBBBBBWBBBWB"

    Returns: "Petya"

  50. {12,13,34,5,39,37,10,33,46,41,16,0,38,16,36,27,0,47,26,2,15,25,41,14,29,10,4,9,34,47,42,38,42,15,3,49,12,24,46,11,18,48,30,35,37,8,20,44,6}

    "BBBWWBWWWWBWWBBWWBWBBBBBWWWBBWWBBWBBBWWWBBBBBBBBBB"

    Returns: "Masha"

  51. {9,43,6,34,48,20,43,32,31,38,42,10,37,26,5,46,30,24,22,0,12,30,27,44,33,29,37,40,8,7,19,9,44,36,23,39,14,28,38,5,25,27,47,3,49,29,4,25,21}

    "BBWBBBBBBBWBWWWBBWWBBWBBBBBWBBBBBBBBBWBBBBBBBBWBBW"

    Returns: "Petya"

  52. {40,10,16,25,15,26,25,19,42,9,47,48,31,19,1,47,45,38,39,16,24,4,8,37,0,28,43,22,40,21,12,15,8,6,27,13,38,46,35,13,49,41,2,2,30,32,33,6,21}

    "BWWBBBWWBWBBWWWWBWWWWWWBWWWWBWBBWBBWWWBBBBBBWWWWBW"

    Returns: "Masha"

  53. {38,1,22,0,40,25,43,49,23,28,39,19,39,26,30,3,14,35,11,8,9,33,12,5,4,36,2,15,25,5,44,37,20,31,12,10,29,14,27,37,49,40,16,43,4,31,3,33,21}

    "BBBBBBBBBBBBBBBBBBBBBBBBWBBBBBBWBBBWBBBBBBBBBBWBBB"

    Returns: "Petya"

  54. {44,9,43,14,0,39,25,27,16,25,15,20,28,6,29,30,0,46,45,2,24,21,8,35,22,17,37,32,19,38,4,1,7,19,42,9,12,26,27,11,16,11,33,7,31,14,28,38,13}

    "BBWBBBBBWBBWBWWWWBBBBWBBBBWWWWBWBWWWBBWBBBWWWBWBWW"

    Returns: "Masha"

  55. {25,49,16,0,7,44,12,6,2,27,1,19,42,26,21,18,46,24,38,5,11,10,40,33,28,23,48,34,3,9,43,35,13,45,8,20,41,15,30,39,32,36,22,14,4,29,17,47,31}

    "BWWWWWWBBBWBBWWWBBBWWBWWBWWBBBBWWBWBWWBWWBWWWBBBWB"

    Returns: "Masha"

  56. {43,20,17,0,24,12,15,47,29,44,47,44,15,36,1,4,39,17,21,39,27,35,31,36,16,43,25,20,42,21,1,12,16,26,27,26,35,29,25,34,31,33,4,33,10,10,42,34}

    "BWWBBBBBBBBBWBWBWBBWBBBBBBWWBBWBBWBWWWWWWBWWWWBBB"

    Returns: "Petya"

  57. {30,3,44,30,35,1,47,25,4,46,2,15,40,10,44,42,36,25,1,4,42,27,41,22,38,12,0,21,2,24,10,41,16,12,47,15,40,24,21,3,38,48,36,22,16,48,46,27}

    "BBWWWWWBBBBBWBBBWBBBBWWBWWBBBBBBBWBBBBBBBWBBBBBWW"

    Returns: "Masha"

  58. {44,46,7,47,37,33,1,31,37,2,24,33,40,16,9,13,4,26,14,8,23,40,7,31,8,16,9,0,47,26,44,46,1,32,14,5,22,29,32,28,29,24,4,28,2,13,22,5}

    "BBWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWWWWWWWW"

    Returns: "Petya"

  59. {7,28,27,46,27,5,26,23,27,21,28,21,22,28,17,21,33,12,43,5,15,19,12,38,33,0,7,13,31,44,35,3,4,24,3,43,25,0,37,1,20,9,5,14,24,30,18}

    "BWWBBBWBWBBWBBBBWBBBBBBBBBBBBBBWBBBWWBWBBWWBBBBB"

    Returns: "Petya"

  60. {4,13,46,7,25,37,26,17,47,49,12,0,24,39,19,23,46,23,41,48,39,33,33,19,16,5,34,31,45,49,35,10,0,7,9,15,10,46,33,19,39,30,19,46,40,36,43,16,1}

    "BWWWWWWBWBBWWWWWWBWBWWWWWBWWWWBWWBWBBBWWBBWWWBBBWB"

    Returns: "Masha"

  61. {48,3,30,44,28,2,36,0,11,40,16,5,9,11,47,8,8,7,43,29,31,33,32,21,10,15,41,32,44,11,30,11,18,42,5,46,18,32,31,17,0,39,29,25,32,20,2,14}

    "BBBWBWBBBWBWBBWWWBBBWWBBWBWBBWWBBBBBWBBBBWWBBBWWB"

    Returns: "Petya"

  62. {0,38,16,37,2,7,22,41,11,46,33,2,45,29,8,27,35,23,15,42,45,41,28,7,2,30,17,42,43,11,37,2,23,48,37,6,1,0,40,26,25,38,8,9,18,1,20,10}

    "BWWWBWWBWBBBBBBWBWWBBWWWBWBWBWWBWWWBBWWBBBBWBBWWW"

    Returns: "Masha"

  63. {19,18,29,21,34,17,3,26,20,5,46,48,30,10,8,11,48,7,4,28,25,0,17,13,0,30,8,26,42,16,16,25,16,39,26,7,4,42,22,37,4,35,5,36,48,6,17,10}

    "BBBBBBBWWWBBWWBWBBWWWBBBBWBBWWBWBWBBBWWBBBBBWWBBB"

    Returns: "Petya"

  64. {0,21,22,5,13,29,22,12,37,0,1,27,38,4,30,23,19,20,44,42,38,37,25,30,0,20,6,45,2,27,14,43,39,35,4,23,43,46,0,24,44,1,20,16,19,1,18}

    "BWWWBWWWBBBBWWWWWBWWWBWWWBWWWWWBBWBWBWWWBBBWBWBB"

    Returns: "Masha"

  65. {27,4,41,42,2,37,48,44,30,9,37,39,44,38,49,27,0,2,29,14,32,11,33,43,36,0,28,33,0,26,33,46,48,31,48,43,46,47,19,0,1,27,22,15,14,14,9,45,40}

    "BWWBBBWWWBBWWWBBWBWBWWWWWWBWWWBBWBBBWWBBBBBWWBBBBB"

    Returns: "Petya"

  66. {2,19,43,33,31,20,6,49,2,36,0,23,42,26,44,32,7,13,37,19,8,9,31,18,11,1,23,46,2,42,0,4,39,27,23,3,23,49,19,0,47,3,14,12,48,32,1,21,11}

    "BBBWWWBWWWWWWBBWWBWBBBWBBBBWWWBBBWWBWWBBWBBBWWWWWW"

    Returns: "Masha"

  67. {6,35,45,17,31,10,39,23,25,8,39,39,41,19,37,22,8,21,9,7,30,5,13,4,40,46,29,13,41,47,20,36,8,1,0,22,30,47,4,12,0,46,9,20,9,25,2,30}

    "BBWBBBBBBWBWWBWWWBWWWWBBWBBBWWWWBWWBWWWBBBWWBWBBB"

    Returns: "Petya"

  68. {21,24,8,6,21,15,33,19,16,31,27,40,35,36,0,26,0,37,39,22,20,16,25,4,37,43,23,22,36,47,21,29,41,8,6,0,12,10,24,2,40,38,7,48,0,31,34,30,28}

    "BBBBBBWWWBBBWBBWBBBWBBWWWWBBBWBWBWBBBWWBWBBWBBWWBB"

    Returns: "Masha"

  69. {26,42,27,19,0,7,26,35,0,1,32,1,38,38,14,40,28,6,26,26,11,26,32,38,22,0,7,1,7,40,5,0,24,3,38,42,22,0,41,26,0,0,26,32,24,3,11}

    "BWWWWBBBWWWWWWBWWWWBWWBWBWBWBWWWWWWBWWWWBBBWWWWW"

    Returns: "Petya"

  70. {44,14,16,22,17,11,42,45,40,28,44,28,30,0,42,0,31,21,31,28,22,44,44,43,21,7,46,0,17,45,0,26,0,28,28,0,44,35,15,31,36,44,10,0,17,0,44}

    "BBWBWBBWBWWWWWWBWWWBBBBWWWBWWWBBBWBWWWWBWBWWWWWB"

    Returns: "Masha"

  71. {16,16,11,8,20,40,29,17,42,20,15,42,29,40,0,0,0,42,31,0,24,43,34,16,42,25,21,29,16,13,40,17,4,17,32,15,2,40,29,15,29,15,16,43,17,0,48,17,42}

    "BWWWWWWWWWWWWBWWBWBWBBBWBWWWWBWWWWWWWWWWBWWBBWWWWW"

    Returns: "Petya"

  72. {18,40,47,31,22,30,30,27,5,30,40,10,25,41,10,18,40,30,21,29,36,10,5,31,30,35,1,18,35,0,0,43,28,28,40,0,1,4,17,0,12,38,21,11,36,7,11}

    "BWBBWWWWBBBBBBBWBBWBBWWBBBWWWWBWWBWWBWBWBWWWBBBW"

    Returns: "Masha"

  73. {9,0,30,9,27,18,21,34,0,13,13,40,0,1,34,29,0,34,41,0,1,0,42,41,2,14,2,47,13,0,14,33,14,0,26,9,34,20,36,9,36,1,27,2,36,43,45,31}

    "BBBWWWWWBBWWWBBWWWWWWWWWWWWBWWWWWWBWBWWWWWWWWBWBB"

    Returns: "Petya"

  74. {21,44,43,9,1,43,47,12,0,30,0,28,33,3,34,28,31,28,44,37,0,28,24,43,43,24,28,0,44,0,27,37,16,12,26,18,34,8,14,16,1,0,28,26,28,0,9}

    "BWWBWBBWWBBWBBWBBWWWBBWBBWBWBWBWBWBBBWBWWBBWWWWW"

    Returns: "Masha"

  75. {7,28,11,46,41,44,0,11,33,44,46,34,7,47,0,29,36,0,13,36,0,28,38,42,7,25,41,38,46,25,14,4,38,7,18,28,28,0,18,25,42,28,2,13,21,0,38,45}

    "BBBWWBBWBBBBWBBBBBBBBBBBBBBBWBBBBBBBBBBBBBWBBWBWB"

    Returns: "Petya"

  76. {37,10,13,5,39,5,49,28,29,37,21,14,10,0,14,38,14,42,44,36,39,13,0,0,0,0,40,40,10,33,2,11,21,37,36,0,0,26,0,37,5,10,14,10,17,29,24,10,10}

    "BBWBBBBBBBWBBWWWWBBBBWWWWBWWBBBBBWWBWWBWWWWBBBWBWW"

    Returns: "Masha"

  77. {45,7,43,10,41,45,45,40,23,0,38,45,43,3,32,36,38,22,39,0,36,45,45,20,38,43,0,37,0,36,6,41,36,4,32,0,20,23,1,36,0,28,0,14,0,38,36}

    "BWBBWBWBBBWBBBWBBBWBBBWBBBWBWBBBWBBBBBWWBBBBBBBB"

    Returns: "Petya"

  78. {45,41,20,27,22,1,4,0,31,0,10,27,3,0,47,8,48,4,4,24,25,8,3,22,0,0,8,12,30,3,24,8,20,12,22,20,20,10,32,24,26,10,30,5,3,3,32,10,8}

    "BWBBWWBBBWWBWBWWWBWWWBBBBWWBBBWWWWBBBBWBBWBBBBBWWW"

    Returns: "Masha"

  79. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    "BBWWBWWWBWWWWWWWWWWWWWWWWBWWWWWWBWWWWWWBWWWWBWWW"

    Returns: "Petya"

  80. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    "BWBBBBWBWBBWBBWWWBWWBWBWWWWWWWWWBBWWBWBBWWWBWWWWW"

    Returns: "Petya"

  81. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    "BWWWBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWBWWWWWWWWWWWW"

    Returns: "Petya"

  82. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    "BWWBWWWWWWWWWWBWBWWWWWWWWBWWWWWWWWWWWWWWWWWWWWWWW"

    Returns: "Petya"

  83. {2,22,9,7,11,9,14,34,23,5,30,16,24,9,32,0,19,3,12,0,13,32,5,31,23,35,1,48,41,0,9,41,6,29,12,43,29,12,1,7,36,46,24,15,22,9,7,0}

    "BBWBWBBBBWBBWBWBBBBBBBWWBBBBBWWWBBBBWBWBWBBBBBBBB"

    Returns: "Masha"

  84. {5,30,43,38,44,20,9,48,39,19,32,22,46,0,16,24,9,27,9,10,27,44,45,2,42,31,3,23,3,23,5,34,22,8,16,32,44,32,21,35,32,8,8,3,9,23,48,0,33}

    "BBBBBBWBBBBBBBBWBWBWWBBBBWBBBBBWBWBWBBBBBBBBWBBBBB"

    Returns: "Petya"

  85. {27,33,16,39,30,31,39,41,40,9,4,38,14,4,45,0,1,15,26,33,11,31,26,38,21,16,18,26,14,4,35,14,11,31,11,46,27,47,0,37,5,32,4,46,12,38,35,16,46}

    "BBBBBWBWWWBBBBBBWWBBBBWWWBBBBBWWBWWBWWBBBWBWWBBBBB"

    Returns: "Petya"

  86. {28,30,44,0,14,28,14,13,31,2,3,48,23,33,33,20,48,45,24,29,4,34,30,39,38,19,29,15,33,7,34,14,21,2,23,7,2,30,31,33,23,23,19,39,43,10,31,36}

    "BWBWBWWBWWWBWWBBBWWBBBWWBWWWWWBBWBBWBWBBWWWWWWWWW"

    Returns: "Petya"

  87. {38,5,1,9,42,17,1,39,40,16,4,1,23,0,23,46,1,3,15,4,2,2,48,27,45,29,40,9,13,2,27,10,39,12,15,4,8,14,40,1,7,36,5,20,47,21,38,7,6}

    "BBWBBBBWBBWWBWBBWWBWBWBWBBBBWWBWBBBBBBBBBBBBBBWWWB"

    Returns: "Petya"

  88. {0,16,46,23,25,40,13,40,39,26,9,21,16,29,40,33,15,25,0,26,23,23,26,30,1,47,39,5,34,5,16,7,8,42,26,25,21,22,37,39,32,28,1,28,0,30,1,46,1}

    "BBBWWBWWWBWWWBBWWWWBWBWWWWBWWBWBBBWWWBWBBWWBBBBWBW"

    Returns: "Masha"

  89. {35,32,19,21,6,42,8,0,37,26,32,6,8,9,8,32,18,4,8,15,7,35,43,21,18,15,26,43,38,21,2,18,2,24,43,10,5,9,30,43,7,33,0,13,7,2,21,11}

    "BWWWWWWBBBWWWWWWWBBWWWBBWWWBWWWBBWWWBWWWBWBBWWBWW"

    Returns: "Masha"

  90. {3,16,33,13,40,20,13,39,40,3,7,41,40,42,13,7,1,16,22,25,35,37,37,47,28,5,42,0,19,16,20,37,35,19,34,25,46,37,24,28,7,0,18,35,42,16,25,49,45}

    "BBBWBBBWBBWBBBBBBBBBBBBWWBBWWBWWBBWWBWBBBWWWWWBWBW"

    Returns: "Masha"

  91. {14,23,42,19,10,28,8,0,38,28,28,42,1,0,32,8,46,42,44,34,46,34,25,1,0,1,21,44,1,14,39,8,20,38,28,44,34,3,3,15,17,32,44,22,27,6,41,45,43}

    "BWWBWBBWBWWBWBWWWWBWWBBBWBBBBWWWBWBWWWBWWBBWBWBBWB"

    Returns: "Petya"

  92. {17,33,9,29,28,25,4,38,0,42,38,48,15,17,1,48,24,0,38,17,38,40,17,46,45,25,47,4,45,48,40,4,41,4,48,33,30,45,30,4,35,4,46,31,0,2,18,34}

    "BWBBBBBBBBBBBBBWBBBBBBBBBWWBWBWBBBBWBBBBBBWBBBWWW"

    Returns: "Masha"

  93. {9,17,30,36,48,2,5,44,12,14,47,37,47,27,36,17,11,23,2,2,36,15,41,5,1,45,25,45,2,21,47,4,29,33,30,16,45,11,2,0,21,44,0,26,46,21,0,36}

    "BWBBBWBBWWWWBWWWBBWWWBWBWBBBWBWWWBBBBWWBBBWWBWBWB"

    Returns: "Masha"

  94. {29,21,18,0,33,35,17,6,11,39,8,5,33,30,1,24,46,28,9,41,34,29,24,14,43,31,40,12,0,33,46,4,31,29,43,28,7,13,13,14,0,33,18,47,44,1,1}

    "BBWBBBBBBBBBWWBBWBWWWBBBBWBBWWWWBBBBBBBBBBBWBBBB"

    Returns: "Masha"

  95. {14,14,8,5,8,46,28,28,38,47,44,14,26,38,41,28,42,30,45,23,7,38,16,5,36,38,43,1,11,27,34,46,24,2,15,11,19,0,32,25,10,8,16,24,44,28,25,36,22}

    "BBBWWBWBBWWBWWBBBWWBWWBBBBBBBWBWBWBBBWBWWBBWBBBBWW"

    Returns: "Petya"

  96. {29,20,46,15,9,45,27,2,27,11,0,44,3,9,28,9,47,17,47,22,0,44,15,47,17,30,40,16,25,40,15,1,23,9,3,13,32,48,18,0,15,37,1,21,28,28,15,42}

    "BWWBBBBWBBBWBWBBWWWBBWBWBBBBWBWBWBBBBBBBWBBBWWBBW"

    Returns: "Masha"

  97. {15,8,39,35,9,27,40,6,11,39,26,39,15,33,6,32,21,22,15,41,31,35,42,39,31,16,17,21,3,19,11,39,17,41,0,17,21,3,41,21,0,15,15,28,44,47,23}

    "BWWWBWBWBBWBWWWWBBWBWBWWBWBBWWBWWBWWWWWWWBWWBWWB"

    Returns: "Masha"

  98. {11,41,27,43,44,7,15,42,37,44,30,23,5,44,0,15,31,38,3,31,43,33,25,22,34,10,15,12,3,31,37,27,3,43,1,23,41,10,16,2,25,26,47,27,29,18,38}

    "BWWBWWWBWWBBWWWBWWBBWBWBBBBBWWBBWBBBBBBBBBWBBBBB"

    Returns: "Petya"

  99. {42,20,20,7,27,0,29,17,0,18,25,15,35,39,3,0,26,35,32,39,22,39,32,23,15,16,11,0,31,46,11,1,28,35,19,42,28,16,13,20,11,0,23,42,44,32,1,17}

    "BWBBWBWBWBBWWBWBBBWBWBWWWBWWWWBWWBBBWBWBWBWBWBWBW"

    Returns: "Masha"

  100. {11,35,37,35,48,22,25,14,37,23,7,25,8,2,1,23,10,0,40,5,23,10,39,37,45,46,24,37,25,0,30,48,39,25,47,24,43,24,37,12,12,16,0,21,23,48,15,3}

    "BWWWWBBWBWWWBBBWBWWWWBBBWBWBBWBWWWWWWBWWBBBBBWWWB"

    Returns: "Masha"

  101. {5,30,43,38,44,20,9,48,39,19,32,22,46,0,16,24,9,27,9,10,27,44,45,2,42,31,3,23,3,23,5,34,22,8,16,32,44,32,21,35,32,8,8,3,9,23,48,0,33}

    "BBBBWBWWBBBWBWWWBWWBWWBWBWWWWWBWBWBBBWBWWWWWBWBWBB"

    Returns: "Masha"

  102. {14,41,20,15,39,46,21,13,42,23,37,24,27,18,42,46,37,21,30,6,0,5,44,3,39,27,0,18,27,21,14,29,7,4,25,20,4,7,37,36,17,1,9,4,37,41,37,42}

    "BBBWBBBWBWWBWBBBBBBWBBBBWBBWBWWBBWBBWBWWBBBWWBBBB"

    Returns: "Petya"

  103. {8,41,0,47,39,33,16,31,24,22,28,36,21,37,29,2,21,7,10,28,19,40,1,5,33,23,4,17,24,25,14,2,27,39,10,38,29,23,30,18,12,0,18,1,23,22,42,10}

    "BBBBBBBBBBBWBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBWBBBBB"

    Returns: "Petya"

  104. {14,10,2,41,7,17,0,1,40,15,29,44,16,9,21,36,30,28,18,12,5,48,47,18,22,15,19,13,48,20,16,40,43,11,4,34,48,9,13,19,33,5,23,45,8,18,2,41}

    "BBBBBBWWWBWWBBBWWWWBWBWWWWWBBWBWBBWWBWWWBWWWWWWBB"

    Returns: "Masha"

  105. {29,22,29,13,7,47,38,10,26,44,41,25,17,35,6,27,23,37,1,43,7,13,18,19,15,21,31,12,2,46,26,39,47,14,0,28,32,19,14,28,27,7,36,46,38,43,11}

    "BBBWBWBBWBBBBBBBWBBBWBBBWBBBBBWBBWWBBBBBBBWBBBBB"

    Returns: "Petya"

  106. {5,23,19,10,28,44,15,42,16,38,27,33,35,45,18,7,22,2,17,32,18,0,8,8,27,34,44,30,33,46,17,41,39,40,4,13,15,20,9,25,31,1,44,33,25,36,8}

    "BBBBWBWWBBBWBBWBWWBBWWWBBBWBBBBBBBWBWBBBBBBBWWWW"

    Returns: "Masha"

  107. {13,22,9,26,17,2,35,30,14,26,44,47,5,43,12,41,34,2,11,9,20,7,14,30,28,20,48,45,45,18,34,27,25,32,42,38,25,0,24,12,37,13,0,39,11,43,16,4}

    "BWBBBBBBBBBBBBBBBBBBBBBBBBBBBBBWBWBBBBBBWBBBBBBBB"

    Returns: "Petya"

  108. {0,13,6,12,2,8,48,17,16,29,42,45,15,34,49,29,18,19,4,5,25,6,20,42,11,33,1,46,48,47,21,23,43,30,36,21,5,13,28,3,48,0,32,45,36,38,9,40,14}

    "BWBBWWWWWWBWWWWBBWBBBWWWBBBBWWBBWWBBWBWBWBBBBBBWBB"

    Returns: "Masha"

  109. {16,39,9,7,47,33,23,0,40,24,44,4,7,29,37,14,35,38,34,14,36,28,15,25,49,18,39,30,24,11,13,6,14,9,21,28,5,17,15,31,19,39,8,45,8,37,6,39,26}

    "BWWWWBBBBBBBWBBBBBBWWBWBBBBBBBBBWBBBBBBBBBBWBBWBWB"

    Returns: "Petya"

  110. {23,15,49,16,35,14,47,20,10,14,38,16,11,45,28,8,33,26,3,35,19,46,46,8,44,17,0,19,13,7,12,37,9,14,48,42,9,26,25,25,30,0,12,46,39,36,43,29,41}

    "BBBBBBBBBWWBBWWWWWBBWBBBBBBBBWWBBWBWBWBBBWWWBWBWBB"

    Returns: "Masha"

  111. {3,15,14,12,0,3,30,31,46,31,26,27,40,36,41,29,9,42,11,17,20,20,48,47,47,44,13,48,5,33,15,48,24,40,15,38,19,22,34,37,16,48,39,42,16,30,4,10}

    "BBWWBBBBBBBBBBWBBBWBBBBBBBBBBBBBBBWBBBBWBBBBBBBBB"

    Returns: "Petya"

  112. {29,10,12,14,34,13,35,11,3,18,2,34,41,17,0,37,25,20,6,16,27,29,12,13,26,27,8,29,31,28,44,40,40,4,9,7,46,41,15,36,22,11,27,32,7,39,40}

    "BBWWBBBBBWWWWBBBBWBWBBWBBBBBBBBWWBBBBBBBBBBBBBBB"

    Returns: "Masha"

  113. {0, 0, 0, 1, 4, 2}

    "BWWWBBB"

    Returns: "Masha"

  114. {0, 1, 0, 3 }

    "BWBWW"

    Returns: "Masha"

  115. {0, 0, 1, 1, 2 }

    "BWBBBW"

    Returns: "Masha"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: