#P11056. Stone Game Strategy
Stone Game Strategy
Stone Game Strategy
Little F wants to play a game but doesn’t want to lose, so he asks for your help to develop a winning strategy.
In the game, there are m stones. Little F and Little B take turns removing stones; Little F moves first, and the player who cannot make a move loses.
You are given a positive integer n. In each move, a player removes k stones (with k a positive integer) subject to one of the following conditions:
- k is a multiple of n, i.e. $$ k = j \times n, \quad j \ge 1. $$
- k is a perfect square and less than n, i.e. $$ k = i^2, \quad \text{with } i^2 < n. $$
The two players will play T games. In each game, n remains fixed, but the number of stones m may vary. Assuming both players play optimally, determine which player has a winning strategy for each game.
inputFormat
The first line contains two integers n and T (the number of stones and the number of games).
Then T lines follow, each containing a single integer m representing the number of stones in that game.
Constraints: All input values are positive integers.
outputFormat
For each game output a single line containing the winner. Print Little F
if the first player (Little F) has a winning strategy, otherwise print Little B
.
sample
4 3
1
2
4
Little F
Little B
Little F
</p>