11568 - Minesweeper   

Description

 The problem is about minesweeper. Given an N*N matrix A whose elements are either 0 or 1. Output the another N*N matrix B. Every element in B is the sum of the adjacency “8” elements in the same location in A. If an element is on the boundary, the adjacency elements may not be “8”.

Input

The input includes multiple test cases. In each test case, the first line contains one integer N. The next N lines follow. Every line contains N elements which are either 1 or 0.

1 <= N <=100

Output

Output N lines. Every line contains N integers. Every two numbers are separated by single space.

Sample Input  Download

Sample Output  Download

Tags




Discuss