0 atcoder#AGC001D. [AGC001D] Arrays and Palindrome

[AGC001D] Arrays and Palindrome

Score : 10001000 points

Problem Statement

Snuke got a present from his mother on his birthday. The present was a pair of two sequences aa and bb, consisting of positive integers. They satisfied all of the following properties:

  • The sum of all elements of aa is NN.
  • The sum of all elements of bb is NN.
  • Any string of length NN that satisfies the following two conditions (1) and (2) will also satisfy the condition (3).
  • (1) Any of the following forms a palindrome: the first a1a_1 letters, the following a2a_2 letters, the following a3a_3 letters and so on.
  • (2) Any of the following forms a palindrome: the first b1b_1 letters, the following b2b_2 letters, the following b3b_3 letters and so on.
  • (3) All NN letters are the same.

He was happy, until one day he lost both of the sequences. Now, he only remembers that the sequence aa was a permutation of another sequence AA of length MM.

To bring him happiness again, his mother has decided to give him another pair of sequences aa and bb that satisfies his favorite properties and is consistent with his memory.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1M1001 \leq M \leq 100
  • 1Ai1051 \leq A_i \leq 10^5
  • The sum of all AiA_i equals NN.

Input

The input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 ...... AMA_M

Output

If there exists a pair of sequences aa and bb that satisfies the properties and is consistent with Snuke's memory, print three lines. The first line must contain the sequence aa, the second line must contain the length of the sequence bb, and the third line must contain the sequence bb.

If such a pair does not exist (because Snuke's memory is wrong or some other reason), print a single line containing the word Impossible (case-sensitive).

3 2
2 1
1 2
1
3
6 1
6
6
3
1 2 3
55 10
1 2 3 4 5 6 7 8 9 10
Impossible