Cookies

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Rie likes to make cookies. She made NN types of cookies. She made A_iA\_i cookies of type ii (1iN1 ≤ i ≤ N). In order to sell the cookies made by her, she will pack them into boxes. However, the following conditions should be satisfied.

  • For every box, the types of the cookies in it should be different.
  • For every box, the number of cookies in it should be equal to one of the following MM numbers: B_1,B_2,,B_MB\_1, B\_2, \dots , B\_M.

Write a program which, given information of cookies made by Rie and the conditions to pack the cookies into boxes, determines whether it is possible to pack all the cookies into boxes. Moreover, if it is possible to pack all the cookies into boxes, your program should output a way to pack the cookies into the minimum number of boxes.

입력

Read the following data from the standard input.

NN

A_1A\_1 A_2A\_2 \cdots A_NA\_N

MM

B_1B\_1 B_2B\_2 \cdots B_MB\_M

출력

If it is possible to pack all the cookies into boxes so that the conditions are satisfied, let xx be the number of used boxes, c_kc\_k be the number of cookies in the kk-th box (1kx1 ≤ k ≤ x), and v_k,1,v_k,2,,v_k,c_kv\_{k,1}, v\_{k,2}, \dots , v\_{k,c\_k} be the types of the cookies in the kk-th box. Write these numbers to the standard output as in the following format.

xx

c_1c\_1 v_1,1v\_{1,1} v_1,2v\_{1,2} \cdots v_1,c_1v\_{1,c\_1}

c_2c\_2 v_2,1v\_{2,1} v_2,2v\_{2,2} \cdots v_2,c_2v\_{2,c\_2}

\vdots

c_xc\_x v_x,1v\_{x,1} v_x,2v\_{x,2} \cdots v_x,c_xv\_{x,c\_x}

Here, the number of used boxes xx should be the minimum possible number. If there are several ways to pack the cookies into boxes satisfying the conditions, output any one of them.

If it is impossible to pack all the cookies into boxes so that the conditions are satisfied, write -1 to the standard output.

제한

  • 1N15,0001 ≤ N ≤ 15\\,000.
  • A_i1A\_i ≥ 1 (1iN1 ≤ i ≤ N).
  • A_1+A_2++A_N15,000A\_1 + A\_2 + \cdots + A\_N ≤ 15\\,000.
  • 1MN1 ≤ M ≤ N.
  • 1B_jN1 ≤ B\_j ≤ N (1jM1 ≤ j ≤ M).
  • B_j<B_j+1B\_j < B\_{j+1} (1jM11 ≤ j ≤ M - 1).
  • Given values are all integers.