Minecraft

Time limit1.52sMemory limit1024 MB

Problem

Think of the following problem while recalling the game Minecraft, released in 2009.

There is a three-dimensional grid $M$ of size $n \times n \times n$. Let $M_{i,j,k}$ be the cell on the $i$-th layer, $j$-th row, and $k$-th column. Each cell contains at most one block. If the cell contains a block, $M_{i,j,k}=1$; otherwise, $M_{i,j,k}=0$.

Project the grid onto the three axis-aligned planes, producing three $n \times n$ two-dimensional grids $H$, $R$, and $C$. They are defined as follows.

  • If $M_{i,j,k}=1$ for at least one layer $i$, then $H_{j,k}=1$; otherwise, $H_{j,k}=0$.
  • If $M_{i,j,k}=1$ for at least one row $j$, then $R_{i,k}=1$; otherwise, $R_{i,k}=0$.
  • If $M_{i,j,k}=1$ for at least one column $k$, then $C_{i,j}=1$; otherwise, $C_{i,j}=0$.

Three grids $H'$, $R'$, and $C'$ are given. Determine whether there exists a three-dimensional grid $M'$ whose projections satisfy $H=H'$, $R=R'$, and $C=C'$.

Input

The first line contains an integer $n$, the side length of the grid. ($1 \le n \le 100$)

The next $n$ lines describe the grid $H'$. Each line is a length-$n$ string consisting of 0 and 1; the $k$-th character of the $j$-th line is $H'_{j,k}$.

The next $n$ lines describe the grid $R'$. Each line is a length-$n$ string consisting of 0 and 1; the $k$-th character of the $i$-th line is $R'_{i,k}$.

The final $n$ lines describe the grid $C'$. Each line is a length-$n$ string consisting of 0 and 1; the $j$-th character of the $i$-th line is $C'_{i,j}$.

Output

If a grid $M'$ satisfying the conditions exists, print YES on the first line.

Then print all $n$ grids of size $n \times n$. Each grid must be printed using $n$ lines, and each line must be a length-$n$ string consisting of 0 and 1. In the $i$-th printed grid, the $k$-th character of the $j$-th line corresponds to $M'_{i,j,k}$.

If several valid grids exist, print any one of them.

If no grid $M'$ satisfies the conditions, print NO on the first line.