Medium Game Theory > Minimax

Mina and Raju love to play interesting games. One day while playing Raju invents a wonderful game. Initially there are R marbles on the table. In a single move Mina and Raju can remove the marbles from the table. But there are rules to follow while playing. For Mina there are **m** types of legal moves and for Raju, there are **n** types of legal moves which are set by Mithu randomly. Say there are 10 marbles initially. Mithu set that there are 2 types of legal moves for Mina and in a single move she can either remove 1 or 3 marbles from the table and 3 types of legal moves for Raju and in a single move he can remove 2 , 4 or 5 marbles from the table same as Mina . You can assume that if n + m = 5 then all legal moves are between 1 to 5 but randomly distributed among Mina and Raju by Mithu . They play alternately and the winner is the one who take the last marble from the table or loser is the one who can’t take marble from the table. Mina always starts and both of them play optimally. Input: ------ Input consists of a number of test cases **T (T <= 1000)** and each case starts with three integer numbers **R** (initial number of marbles in the table), **m** (legal moves for Mina), **n** (legal moves for Raju). The next line contains m space separated integers forming legal moves of Mina and very next line contains n space separated integers forming legal moves of Raju. Output: ------- For each input, output one line saying either “Mina wins” or “Raju wins”. Constrains: ----------- T <= 1000 R <= 1000 n + m <= 15 Sample Input ------------ 2 10 2 3 1 3 2 4 5 2 1 1 2 1 Sample Output ------------- Raju wins Mina wins

Shakil Ahmed