Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-nollarni-tarqatish

Spread the zeros

Medium 1000 ms 64 MB 46%
Share

A matrix of size $n \times m$ is given. For every cell that holds $0$ in the original matrix, its whole row and its whole column become zero. (Only the original zeros count: zeros that appear along the way do not clear their own row and column.) Print the resulting matrix.

A matrix: the rows and columns of the zero cells are crossed out to zero

Input

The first line contains two positive integers $n$ and $m$.
Each of the next $n$ lines contains $m$ integers — the matrix.

Output

$n$ lines with $m$ integers each.

Note

$1 \le n, m \le 100$
$-1000 \le a_{i,j} \le 1000$

Examples

Input #1
3 4
1 2 3 4
5 0 7 8
9 10 11 0
Output #1
1 0 3 0
0 0 0 0
0 0 0 0
Input #2
2 2
1 2
3 4
Output #2
1 2
3 4

Sign in to submit a solution

Signing up is free and takes a minute.