# Matrix Decompressing

Some R × C matrix of positive integers is encoded and represented by its R cumulative row sum and C column sum entries. Given, R, C and those R + C cumulative row sum and column sums, you want to decode the matrix (i.e., find all the individual R ∗ C entries). Here, RowSum(i) = CumulativeRowSum(i) = ColumnSum(i) = row sum is the sum of all the row sums from row 1 to row i (inclusive). Input There can be multiple test cases. The first line of input contains the number of test cases, T (1 ≤ T ≤ 100). Each test case contains 3 lines of input. The first line of the test case gives the size of the matrix: thenumberofrows,R(1≤R≤20)andthenumberofcolumnsC(1≤C≤20). Thenextline contains all the R cumulative row sums, and the last line of the test case contains the C cumulative column sums. Any two successive numbers in the same line is separated by a single space. Output For each test case print the label of the test case in the first line. The format of this label should be “Matrix x” where x would be replaced by the serial number of the test case starting at 1. In each of the following R lines print C integers giving all the individual entries of the matrix. You can assume that there is at least one solution for each of the given encodings. To simplify the problem further, we add the constraint that each entry in the matrix must be an integer between 1 and 20. In case of multiple solutions, you can output any one of them. Sample Input 2 34 10 31 58 10 20 37 58 34 10 31 58 10 20 37 58 Ajk Or in other words, the i-th row sum is the sum of all the entries in row i. And the cumulative i-th CumulativeColumnSum(i) = ∑C j=1 Aij ∑i ∑C k=1 j=1 ∑R j=1 ∑i ∑R k=1 j=1 Akj Aji

2/2 Sample Output Matrix 1 1612 1 2 2 16 8 2 14 3 Matrix 2 1117 1 1 7 12 8892