407646: GYM102862 J Mex Grid

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Mex Gridtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given two arrays of integers $$$a$$$ and $$$b$$$. The length of $$$a$$$ is $$$n$$$ and the length of $$$b$$$ is $$$m$$$. Your task is to find any matrix $$$C$$$ of size $$$n \times m$$$, which satisfies all of the following properties:

  • all integers in the interval $$$[0,n\cdot m-1]$$$ should be in $$$C$$$ exactly once,
  • the mex of the $$$i$$$-th row should be equal to $$$a_i$$$,
  • the mex of the $$$j$$$-th column should be equal to $$$b_j$$$.

Mex stands for "minimum excluded": the mex of a set of numbers is equal to the smallest non-negative integer which is not present in the set. For example, $$$\text{mex}(\{0,1,2,4\})=3$$$.

Input

The first line contains two positive integers $$$n$$$ and $$$m$$$, the lengths of the arrays $$$a$$$ and $$$b$$$ ($$$1 \leq n \cdot m \leq 10^5$$$). The second line contains $$$n$$$ integers $$$a_1$$$, $$$\ldots$$$, $$$a_n$$$ ($$$0 \leq a_i \leq 10^9$$$). The third line contains $$$m$$$ integers $$$b_1$$$, $$$\ldots$$$, $$$b_m$$$ ($$$0 \leq b_i \leq 10^9$$$).

Output

If there exists such a matrix, output "Yes" in the first line. Otherwise, output "No".

In the first case also output the required matrix. Output $$$n$$$ rows of $$$m$$$ integers, where the the $$$j$$$-th integer of the $$$i$$$-th row is $$$C_{i,j}$$$. Each integer from the interval $$$[0,n\cdot m -1]$$$ should appear exactly once in $$$C$$$. If there exist multiple such matrices, output any of those.

ExamplesInput
2 2
2 0
1 0
Output
Yes
0 1 
3 2 
Input
2 2
1 1
1 1
Output
No

加入题单

上一题 下一题 算法标签: