Codeforces Round 298 (Div. 2)
F
Simplified Nonogram
Codeforces
2400
原题
← E→
翻译中…

In this task you have to write a program dealing with nonograms on fields no larger than $5 × 20$.

翻译中…

Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about rows and columns. For each row and each column the number of contiguous black segments is specified.

翻译中…

For example if size of the field is $*n* = 3, *m* = 5$, аnd numbers of contiguous black segments in rows are: $[2, 3, 2]$ and in columns are: $[1, 0, 1, 2, 1]$ then the solution may look like:

翻译中…

image

翻译中…

It is guaranteed that on each test in the testset there exists at least one solution.

翻译中…

Input

翻译中…

In the first line there follow two integers $*n*$, $*m*$ ($1 ≤ *n* ≤ 5, 1 ≤ *m* ≤ 20$) — number of rows and number of columns respectively.

翻译中…

Second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ where $*a*_{*i*}$ is the number of contiguous black segments in $*i*$-th row of the field.

翻译中…

Similarly, third line contains $*m*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*m*}$ where $*b*_{*i*}$ is the number of contiguous black segments in the $*i*$-th column of the field.

翻译中…

It is guaranteed that there exists at least one solution.

翻译中…

Output

翻译中…

Output any possible solution. Output should consist of $*n*$ lines each containing $*m*$ characters. Denote white cell as "." and black cell as "*".

翻译中…

样例

Input #1
3 5
2 3 2
1 0 1 2 1
Output #1
*.**.
*.*.*
*..**
InputCopy OutputCopy
Input #2
3 3
2 1 2
2 1 2
Output #2
*.*
.*.
*.*
InputCopy OutputCopy
Input #3
3 3
1 0 1
2 2 2
Output #3
***
...
***
InputCopy OutputCopy
题目信息
题号
534F
时间限制
2 s
内存限制
256 MB
标签
位运算
动态规划
哈希
折半搜索

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。