TAKE4 - Take Away Game
Two players play the following game:
a) A number N is chosen
b) players move alternately starting from player1
c) On his turn, a player may subtract either 1, 2 , 3 .. or M ( M <= N ) from N.
d) The player to make N equal to 0, wins.
e) Both play optimally. That is, if there is a move which makes a player win, he is sure to find it.
Given the starting value N, determine who wins the game.
First line consists of the number of test cases T (T <= 1000). Each of the next T lines consists of two integers, the numbers N and M (1 <= N <= 2000).
You must ouput T lines. Output "player 1 wins" (without quotes) if the first player wins, else output "player 2 wins"