QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#13194. Filling Numbers in Squares

Statistics

A grid-filling game has recently become popular worldwide: Given an $n \times m$ grid. The rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. A cell is called an "odd cell" if both its row index and column index are odd. At the start of the game, all odd cells are filled with numbers. You need to fill in the remaining cells such that the grid satisfies the following conditions:

  1. The sum of all numbers in any $a_1 \times b_1$ subgrid is greater than $0$.
  2. The sum of all numbers in any $a_2 \times b_2$ subgrid is less than $0$.

Here, $a_1, b_1, a_2, b_2$ are given at the start of the game. An $a \times b$ subgrid is defined as the set of all cells with row indices between $i$ and $i+a-1$ (where $1 \le i \le n-a+1$) and column indices between $j$ and $j+b-1$ (where $1 \le j \le m-b+1$).

Little P likes this game very much and hopes you can help him write a program to provide a filling scheme, or tell him that no such scheme exists.

Input

The first line contains 6 positive integers $n, m, a_1, b_1, a_2, b_2$, all between $1$ and $100$.

Starting from the second line, there are $\lceil \frac{n+1}{2} \rceil$ lines, each containing $\lceil \frac{m+1}{2} \rceil$ integers. The $k$-th integer ($k=1, 2, \dots, \lceil \frac{m+1}{2} \rceil$) on the $(i+1)$-th line represents the integer filled in the cell at row $2i-1$ and column $2j-1$ at the start of the game.

These integers are between $-100$ and $100$.

Output

If no filling scheme exists, output a single line "No".

If a filling scheme exists, first output "Yes". Then, output $n$ lines, each containing $m$ space-separated integers, describing a filling scheme. Every integer in the output must be between $-10^9$ and $10^9$.

Examples

Input 1

3 3 2 2 3 3
1 1
1 1

Output 1

Yes
1 -1 1
-4 5 -4
1 -1 1

Note 1

After filling in the numbers, the sum of the numbers in any $2 \times 2$ subgrid is $1$; the sum of the numbers in any $3 \times 3$ subgrid is $-1$.

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.