For this Question: You are given a matrix Mat of m rows and n columns. The matrix is boolean so the elements of the matrix can only be either 0 or 1.
Now, if any row of the matrix contains a 1, then you need to fill that whole row with 1. After doing the mentioned operation, you need to print the modified matrix.The first line of input contains T denoting the number of test cases. T test cases follow.
The first line of each test case contains m and n denotes the number of rows and a number of columns.
Then next m lines contain n elements denoting the elements of the matrix.

Constraints:
1 &le; T &le; 20
1 &le; m, n &le; 700
Mat[I][j] ∈ {0,1}For each testcase, in a new line, print the modified matrix.Input:
1
5 4
1 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1

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

Explanation:
Rows = 5 and columns = 4
The given matrix is
1 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
Evidently, the first row contains a 1 so fill the whole row with 1. The third row also contains a 1 so that row will be filled too. Finally, the last row contains a 1 and therefore it needs to be filled with 1 too.
The final matrix is
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
1 1 1 1, I have written this Solution Code: import java.io.*;

import java.util.*;








class Main {
        public static void main(String[] args) throws Exception{
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader bf = new BufferedReader(isr);
        int t = Integer.parseInt(bf.readLine());
        while (t-- > 0){
            String inputs[] = bf.readLine().split(" ");
            int m = Integer.parseInt(inputs[0]);
            int n = Integer.parseInt(inputs[1]);

            String[] matrix = new String[m];
            for(int i=0; i<m; i++){
                matrix[i] = bf.readLine();
            }
            StringBuffer ones = new StringBuffer("");
            StringBuffer zeros = new StringBuffer("");
            for(int i=0; i<n; i++){
                ones.append("1 ");
                zeros.append("0 ");
            }
            for(int i=0; i<m; i++){
                if(matrix[i].contains("1")){
                    System.out.println(ones);
                }else{
                    System.out.println(zeros);
                }
            }
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?