Given a Matrix A of N x M elements. Your task is to make Zeroes, that means in whole Matrix when you find a zero, convert its upper, lower, left, and right value to zero and make that element the sum of the upper, lower, left and right value. Do the following tasks according to the initial Matrix.
Output Array should look like:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines.
First line of each test case consist of two space separated integers N and M, denoting the number of element in a row and column respectively.
Second line of each test case consists of N*M space separated integers denoting the elements in the matrix in row major order.
It should be single line output, Print the respective output in the respective line.
1 2 3 4 5 6 0 7 8 9 4 6 8 4 5 2
1 2 0 4 5 0 20 0 8 9 0 6 8 4 5 2
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.