pits are arranged in a row. For each natural number from to , let j_k represent the number of stones in the -th pit, counting from left to right.
Consider a sequence of natural numbers l_1, l_2, …, l_m, which is strictly increasing for some natural number greater than .
Two players engage in the following game:
During a turn, a player can move stones from any pit to the adjacent pit on the right. The number of stones moved must be one of the numbers l_1, l_2, …, l_m.
A player loses if they cannot make a move (i.e., when the number of stones in every pit, except the rightmost one, is less than l_1).
The first line contains the natural numbers and , both ranging from to inclusive.
The second line provides a sequence of non-negative integers: j_1, j_2, …, j_n.
The third line lists a sequence of natural numbers: l_1, l_2, …, l_m, which is increasing, and the sum l_1 + l_2 + … + l_m is less than .
The game's position is defined by the arrangement of stones in the pits and the player whose turn it is. It is known that the total number of possible game positions does not exceed .
Write a program that outputs on the first line the number of the player (the -st player moves first, followed by the -nd) who can guarantee a win. If the winner is the -st player, each subsequent line should contain non-negative integers, representing the number of stones in the pits after the -st move that leads to the -st player's victory. List all possible move options in any order, with one line per move option.
Example 1