m = int(input())
matrix = [[int(_) for _ in input().split()] for __ in range(m)]
matrix = [[1 if i + j + 1 >= m else matrix[i][j] for j in range(m)] for i in range(m)]
[print(*_) for _ in matrix]
m = int(input())
matrix = [[int(_) for _ in input().split()] for __ in range(m)]
matrix = [[1 if i + j + 1 >= m else matrix[i][j] for j in range(m)] for i in range(m)]
[print(*_) for _ in matrix]