A finite number of chips are arranged in a row, each numbered consecutively with natural numbers starting from . Two players take turns removing either one chip or two adjacent chips (where the numbers differ by ). The winner is determined by one of the following conditions:
(1) The player who makes the last move wins.
(2) The player who forces the opponent to make the last move wins.
Your task is to create a program that, for any given game variant (1 or 2) and any initial game position, identifies all winning moves. A winning move is one that guarantees a victory, assuming optimal play from that point onward, regardless of the opponent's actions.
The input consists of:
A number or , indicating the game variant.
A list of available chip numbers, each less than .
The output should have two lines:
The first line should list, in ascending order, the numbers of chips that, when removed individually, constitute a winning move from the given position.
The second line should list, in ascending order, the numbers of chips that, when removed along with the next chip, constitute a winning move.
If there are no winning moves for a line, it should be left empty. Each non-empty line should end with a space followed by an end-of-line marker.
Example 1