Universal Cup Judging System

Universal Cup

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

You are given a binary $n \times m$ matrix $A$. Basically, it is just a table of $n$ rows and $m$ columns, each cell of which has a value of $0$ or $1$.

In one move, you can pick a cell $(i, j)$ of this matrix and flip the values in it and in all cells that share a common side with it. Formally, for every cell $(s, t)$ ($1 \le s \le n, 1 \le t \le m$) such that $|s - i| + |t - j| \le 1$, the transformation $A_{s,t} \leftarrow 1 - A_{s,t}$ is applied.

Find a way to make the matrix have only zero elements, or state that it is impossible.

Input

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 500$), denoting the sizes of the matrix.

The $i$-th of the following $n$ lines contains a binary string of $m$ digits, corresponding to the $i$-th row of the matrix.

Output

If there is no solution, print the word NO in a single line.

Otherwise, print the word YES in the first line. In each of the following $n$ lines, print a binary string of length $m$. These strings form a matrix with dimensions $n \times m$. Each of its elements has to be equal to $1$ if and only if you intend to make a move corresponding to that cell.

Of course, the combination of all picked moves must result in the conversion of the initial matrix into the matrix consisting of only zeros.

If there are several solutions, print any of them.

You may output words in any case, upper or lower.

Example

Sample Input 1

3 4
1000
0001
0100

Sample Output 1

YES
0100
0110
1100

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.