#P7656. [BalticOI 1996] A NUMBER GAME (Day 2)

[BalticOI 1996] A NUMBER GAME (Day 2)

Description

Below is a game. First, we assign integer values to the variables nn and mm. Players A and B then take turns making moves (A goes first). In each move, a positive integer kmin{m,n}k \le \min \lbrace m,n \rbrace is chosen, which decreases the value of nn by kk. However, it is not allowed to use a number that has already been used in any previous move by either player. The game ends when one player cannot make a move. The player who makes the last move wins.
Please write a program to determine which player has a winning strategy.

Input Format

The first line contains two integers nn and mm, separated by a space.

Output Format

The first line: who has a winning strategy. The following lines: list all possible first moves of A in increasing order, followed by the word “winning” or by a winning response of B.

3 2
B wins
1 2
2 1
7 4
A wins
1 winning
2 winning
3 4
4 3

Hint

Constraints

For 100%100\% of the testdata, 0<n700 < n \le 70, 0<m200 < m \le 20.

Scoring

The score of this problem follows the original BOI setting, with a full score of 4040.

Problem Notes

From Baltic Olympiad in Informatics 1996: Day 2:A NUMBER GAME.
Translated and organized by @求学的企鹅.

Translated by ChatGPT 5