AlgoUniversity
  • Go Back
Discussion
Set Matrix Zeros :

Author

Rishabh Verma

Difficulty Level : Easy

Submissions : 160

Asked In : Paytm

Marks :10

: 2 | : 0

Given a matrix, A of size M x N of 0s and 1s. If an element is 0, set its entire row and column to 0.

Input

First line contains two space separated integers M and N ($$$1 \le M$$$,$$$N \le 1000$$$) represents the number of Rows and Columns respectively.

Each of the next M lines contains N space separated integers $$$A_i$$$ ($$$0 \le A_i \le 1$$$).

Output

Print M rows where each row contains N space separated integers either 0 or 1 representing final matrix.

Examples

Input
5 5
1 1 1 1 1
1 1 0 1 1
1 0 1 1 1
1 0 1 1 0
1 1 0 0 1
Output
1 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
Input
3 3
1 1 0
1 1 1
1 1 1
Output
0 0 0 
1 1 0 
1 1 0 

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.