AT_arc214_a [ARC214A] Same Sum Grid Path

Description

There is an $ N \times N $ grid. Let $ (i,j) $ denote the cell at the $ i $ -th row from the top and $ j $ -th column from the left. You are given $ N \times N $ characters $ S_{1,1}, \dots , S_{N,N} $ . Each character is a digit (`0` to `9`) or `?`. Determine if it is possible to replace each `?` with a digit to satisfy the following condition, and if possible, output one such way of replacement. > For each $ 1 \le i,j \le N $ , write $ S_{i,j} $ as an integer in cell $ (i,j) $ . > For a path from cell $ (1,1) $ to cell $ (N,N) $ by repeating moves only to adjacent cells to the right or down, let the **score** of the path be the sum of the integers written in the cells on the path (including the start and end points). > Then, for all $ \binom{2N-2}{N-1} $ possible paths, the scores are all equal.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ S_{1,1} $ $ S_{1,2} $ $ \ldots $ $ S_{1,N} $ $ S_{2,1} $ $ S_{2,2} $ $ \ldots $ $ S_{2,N} $ $ \vdots $ $ S_{N,1} $ $ S_{N,2} $ $ \ldots $ $ S_{N,N} $

Output Format

If it is impossible to make a replacement that satisfies the condition, output `-1`. If possible, output $ S_{1,1}, \dots , S_{N,N} $ after the replacement in the following format: > $ S_{1,1} $ $ S_{1,2} $ $ \ldots $ $ S_{1,N} $ $ S_{2,1} $ $ S_{2,2} $ $ \ldots $ $ S_{2,N} $ $ \vdots $ $ S_{N,1} $ $ S_{N,2} $ $ \ldots $ $ S_{N,N} $ If there are multiple solutions, any of them will be accepted.

Explanation/Hint

### Sample Explanation 1 It is possible to replace `?` with digits so that the scores of all paths are $ 3 $ . ### Sample Explanation 2 No replacement can satisfy the condition. ### Constraints - $ 2 \le N \le 100 $ - $ S_{i,j} $ is a digit (`0` to `9`) or `?`.