Buttons

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

There is an H×WH \times W grid, with one button in each cell. Initially, all buttons are off. You will push them and turn them on.

Your task is to find a "good" timing of pressing the buttons. Let t_ijt\_{ij} be the timing to push the button of row ii and column jj. The timing is said to be "good" if and only if the following conditions are satisfied.

  • t_ijt\_{ij} is an integer between 00 and 10910^9 for all ii and jj.
  • t_kl+a_ijt_ijt_kl+b_ijt\_{kl} + a\_{ij} \le t\_{ij} \le t\_{kl} + b\_{ij} for every cell klkl which is a horizontal or vertical neighbor of the cell ijij, i.e., ik+jl=1|i - k| + |j - l| = 1.

Write a program to output a "good" timing for the given aa and bb. If there are several possible timings, you can output any of them. If there is no "good" timing, you should output 1-1.

입력

The input consists of a single test case of the following format.

HH WW

a_11a\_{11} \dots a_1Wa\_{1W}

\vdots

a_H1a\_{H1} \dots a_HWa\_{HW}

b_11b\_{11} \dots b_1Wb\_{1W}

\vdots

b_H1b\_{H1} \dots b_HWb\_{HW}

HH and WW represent the height and width of the given grid (wH,W50w \le H, W \le 50). a_ija\_{ij} and b_ijb\_{ij} represent the range of time differences for the button of row ii and column jj (100,000a_ijb_ij100,000-100,000 \le a\_{ij} \le b\_{ij} \le 100,000).

출력

If there is a "good" timing, output it in the following format.

T_11T\_{11} \dots T_1WT\_{1W}

\vdots

T_H1T\_{H1} \dots T_HWT\_{HW}

T_ijT\_{ij} is an integer representing the timing to push the button of row ii and column jj. The timings should satisfy the conditions defined in the problem statement. If there are multiple correct answers, you can print any of them.

If there is no "good" timing, you should output 1-1 instead.