#P4077. [SDOI2016] 硬币游戏
[SDOI2016] 硬币游戏
Description
Alice and Bob are playing a game with coins numbered from to . Each coin has two sides, called heads and tails. Initially, some coins are heads up and some are tails up. Alice and Bob alternate performing flip operations on these coins, and Alice always moves first.
Specifically, on each turn, the player may choose an index such that the coin is currently tails up. For the index , we can always write , where and are non-negative integers, and is a non-negative integer that is coprime to both and . Then there are two choices:
-
Choose integers satisfying , , and , then simultaneously flip all coins with indices , where .
-
Choose integers satisfying , , and , then simultaneously flip all coins with indices , where .
It can be seen that the game cannot continue indefinitely. When a player cannot make a move as described above, they lose the game. As the first player, Alice wants to know beforehand whether she can win. She assumes that both she and Bob are perfectly rational, so during the game both will optimize their strategies and try to avoid losing.
Input Format
There are multiple test cases. The first line contains an integer , the number of test cases. Then test cases follow.
For each test case, the first line contains two integers .
The second line contains integers. The -th number denotes the initial state of the -th coin: means tails up, and means heads up.
Output Format
Output lines. For each test case, if Alice has a winning strategy as the first player, print win; otherwise print lose.
6
16 14
1 0 0 1 0 0 0 0 1 0 0 0 1 0 1 1
16 14
0 1 0 0 0 1 1 1 1 1 1 0 1 0 0 1
16 11
0 1 0 0 0 1 1 1 0 1 0 0 0 1 0 1
16 12
1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0
16 4
1 0 0 1 0 0 1 0 0 0 0 1 0 1 1 0
16 20
0 0 0 0 1 0 1 0 0 0 1 0 0 1 0 0
win
lose
win
lose
win
win
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号