Bar Code

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

문제

Bar Code is a puzzle game invented by Thinh Van Duc Lai in 2017 that was first published in the New York Times.  Bar Code is played on a square grid consisting of n×nn \times n unit squares with (n+1)×(n+1)(n+1) \times (n+1) grid points.  For a given specification, the puzzle requires the marking of some of the borders of these unit squares by drawing a vertical or horizontal bar, subject to the following conditions:

  • For each row/column, the specification describes exactly how many separate groups of consecutive bars of the same orientation (vertical and horizontal, resp.) there should be in this row/column. For instance, if the specification demands 2 1 1, then there have to be 33 groups of 22, 11, and 11 bars, separated by at least one unmarked border.  For example, for a n=6n = 6 puzzle with 77 borders in each row, the following markings would meet this specification:
    1101010
    1101001
    1100101
    0110101
    
    where 1 denotes the presence of a bar and 0 denotes a border that is unmarked.
  • No 22 bars may touch.  

The illustration shows the solution for sample input 33.

Find a marking that is consistent with the given specification!

입력

The input consists of a single test case. The first line contains a single integer nn (0<n90 < n \le 9). This is followed by nn lines. The ithi^{\text{th}} line contains 11 or more non-negative integers denoting the sizes of groups that must be formed by the vertical bars in row ii (counting from the top). If the line contains the single integer 00, then no borders may be marked for that row.  Otherwise, none of the integers on the line will be 00.

Following that will be another nn lines. The jthj^{\text{th}} line contains 11 or more non-negative integers denoting the sizes of groups that must be formed by the horizontal bars in column jj (counting from the left). If the line contains the single integer 00, then no borders may be marked for that column.  Otherwise, none of the integers on the line will be 00.

출력

Output the solution as follows.  On the first nn lines, output a string of length n+1n+1 consisting of 1 and 0 characters.  The ithi^{\text{th}} string should contain a 1 in position jj if and only if the jthj^{\text{th}} vertical border in row ii should be marked as a bar. On the next n+1n+1 lines, output a string of length nn also consisting of 1 and 0 characters.  The ithi^{\text{th}} string should contain a 1 in position jj if and only if the ithi^{\text{th}} horizontal border in column jj should be marked as a bar. Rows are counted top down and columns are counted left to right.

If there are multiple solutions, you may output any of them! You may assume that at least one marking exists that is consistent with the specification.