Matrix Transpose A matrix is a rectangular array of elements, most commonly numbers. A matrix with m rows and n columns is said to be an m-by-n matrix. For example, 1 3 2 0 4 -1 0 0 0 5 -2 11 is a 4-by-3 matrix of integers. The transpose of a matrix is formed by interchanging the rows and columns of the matrix. That is, the element in row i, column j of the transpose is the element in row j, column i of the original matrix. For example, the transpose of matrix above is: 1 0 0 5 3 4 0 -2 2 -1 0 11 A matrix is said to be sparse if there are relatively few non-zero elements. As an m-by-n matrix has mn elements, storing all elements of a large sparse matrix may be inefficient as there would be many zeroes. There are a number of ways to represent sparse matrices, but essentially they are all the same: store only the non-zero elements of the matrix along with their row and column. You are to write a program to output the transpose of a sparse matrix of integers. Input ----- The input will consist of multiple instances. Each instance begins with a line containing two numbers, m and n. Then there are 2 lines for each of the m rows of the input matrix. The first line gives the number, r, of non-zero entries in the row, followed by a list of the column indices of all non-zero entries in the row (in ascending order). The second line gives all the non-zero values in that row, from left to right. For example, the array above would be represented as: 4 3 3 1 2 3 1 3 2 2 2 3 4 -1 0 3 1 2 3 5 -2 11 Note that for a row with all zero elements, the corresponding set would just be one number, `0', in the first line, followed by a blank line. You may assume: - the dimension of the sparse matrix would not exceed 10000-by-10000, - the number of non-zero element would be no more than 1000, - each element of the matrix would be in the range of -10000 to 10000, and - each line has no more than 79 characters. The last instance will have m=n=0, and you should not process this case. Output ------ For each input case, the transpose of the given matrix in the same representation. (You may again assume that each line will have no more than 79 characters.) Do not leave a blank line between outputs for different instances. Sample Input ------------ 4 3 3 1 2 3 1 3 2 2 2 3 4 -1 0 3 1 2 3 5 -2 11 0 0 Sample Output ------------- 3 4 2 1 4 1 5 3 1 2 4 3 4 -2 3 1 2 4 2 -1 11