Find winner of the Game of Nim
Submissions: 3043   Accuracy:

69.04%

  Difficulty: Easy   Marks: 2

In Game of Nim, two players take turns removing objects from heaps or the pile of stones.
Suppose two players A and B are playing the game. Each is allowed to take only one stone from the pile. The player who picks the last stone of the pile will win the game. Given N the number of stones in the pile, the task is to find the winner, if player A starts the game .

Input:
The input line contains T, denoting the number of test cases. Then T test case follows, a single line of the input containing a positive integer N.

Output:
Print the winner i.e. Player A or Player B for each testcase in a separate line.

Constraints:
1 <= T <= 100
1 <= N <= 1000

Example:
Input:

2
3
15

Output:
Player A

Player A

Explanation:
Testcase 1: Player A remove stone 1 which is at the top, then Player B remove stone 2
and finally player A removes the last stone.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sahil Chhabra
Author: Sahil_Chhabra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.