Pretty Tables
Consider a table of size M×N, where each cell contains non-negative integers. We define the table as "nice" if, for every row i, the sum of the numbers does not exceed R_i, and for every column j, the sum of the numbers does not exceed C_j.
You are provided with a table Z of size M×N, where some cells already contain non-negative integers. Your task is to find a nice table with the maximum possible sum of elements, ensuring it matches Z in the cells where Z has specified numbers.
Input
The first line of the input contains the integers M and N (1 ≤ M, N ≤ 20). The second line lists M non-negative integers: R_1, R_2, ..., R_M. The third line lists N non-negative integers: C_1, C_2, ..., C_N. All constraints are no greater than 10^6. The next M lines each contain N integers, representing Z. If a cell in the table does not contain a number, it is represented by -1 in the input.
Output
Output the resulting table as M rows of N numbers. If no solution is possible, output the single number -1.