2 players A & B takes turns alternatively and play a game. The game is that they have N numbers on a paper. At any turn a player can replace one of the numbers by any of its factor **( except for 1 & itself ). **The player who is unable to make a move looses the game. Find the winner of the game if A starts the game and both play optimally.

**Input:**

The first line has an integer T denoting the number of test cases.Then T test cases follow. The first line of each test case has an integer N denoting the number of numbers on the paper. The next line consists of N numbers.

**Output:**

For each test case print in a new line the winner, ie either A or B.

**C**onstraints:

1<=T<=100

1<=N<=1000

1<=Ai<=1000

**Example:
Input:**

2

3

5 7 3

4

2 4 7 11

B

A

In the first case, the numbers cannot be replaced by any other number so A can not make a move and B is the winner.

In the second case, player A can replace 4 by 2 and thus the numbers left will be 2 2 7 & 11 and all are irreplacable and thus A is the winner.

Author: whiteman

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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

devsinghindra | 80 |

PiyushPandey4 | 614 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 443 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.