BETA

Submissions : 3343 Accuracy :

41.55

Boolean Matrix Problem
     

Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make all the cells of ith row and jth column as 1.

Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is r and c,r is the number of rows and c is the number of columns.
The second line of each test case contains all the elements of the matrix in a single line separated by a single space.

Output:

Print the modified array.

Constraints:

1 ≤ T ≤ 50
1 ≤ r,c ≤ 20
0 ≤ Elements of matrix ≤ 1

Example:

Input:
3
2 2
1 0 0 0
2 3
0 0 0 0 0 1
3 4
1 0 0 1 0 0 1 0 0 0 0 0

Output:
1 1 1 0
0 0 1 1 1 1
1 1 1 1 1 1 1 1 1 0 1 1

 

**For More Examples Use Expected Output**


Set Default Code

					   
Result:
It is recommended to test your code before clicking 'Submit' button!



                   



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.