Pebbles
n pits are arranged in a row. For each natural number k from 1 to n, let j_k represent the number of stones in the k-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 m greater than 1.
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).
Input
The first line contains the natural numbers n and m, both ranging from 2 to 5 inclusive.
The second line provides a sequence of n non-negative integers: j_1, j_2, …, j_n.
The third line lists a sequence of m natural numbers: l_1, l_2, …, l_m, which is increasing, and the sum l_1 + l_2 + … + l_m is less than 246.
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 1000.
Output
Write a program that outputs on the first line the number of the player (the 1-st player moves first, followed by the 2-nd) who can guarantee a win. If the winner is the 1-st player, each subsequent line should contain n non-negative integers, representing the number of stones in the pits after the 1-st move that leads to the 1-st player's victory. List all possible move options in any order, with one line per move option.