#P1418. [TJOI2011] 构造矩阵

[TJOI2011] 构造矩阵

Description

Construct an n×mn\times m 0101 matrix such that the number of 11s in each row is r1,r2,,rnr_1,r_2,\ldots,r_n, and the number of 11s in each column is c1,c2,,cmc_1,c_2,\ldots,c_m.

Among all valid matrices, the result should be lexicographically smallest. When comparing two matrices in lexicographical order, first compare the first row; if they are equal, compare the second row; and so on.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers r1,r2,,rnr_1,r_2,\ldots,r_n.

The third line contains mm integers c1,c2,,cmc_1,c_2,\ldots,c_m .

Output Format

Output an n×mn\times m matrix.

2 3
2 1 
1 0 2 

101
001

Hint

For 100%100\% of the testdata, n,m100n,m\le 100.

Translated by ChatGPT 5