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

Description

Below is a game. First, we assign integer values to the variables $n$ and $m$. Players A and B then take turns making moves (A goes first). In each move, a positive integer $k \le \min \lbrace m,n \rbrace$ is chosen, which decreases the value of $n$ by $k$. 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 $n$ and $m$, 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.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, $0 < n \le 70$, $0 < m \le 20$. #### Scoring The score of this problem follows the original BOI setting, with a **full score** of $40$. #### Problem Notes From Baltic Olympiad in Informatics 1996: [Day 2:A NUMBER GAME](https://boi.cses.fi/files/boi1996_day2.pdf). Translated and organized by @[求学的企鹅](/user/271784). Translated by ChatGPT 5