cho.sh
Notes
Loading...

Number of Papers

Time limit

2s

Memory limit

256 MB

Problem

You are given an N×N square paper represented as a matrix. Each cell contains one of the numbers -1, 0, and 1.

Cut the paper by the following rules.

  1. If every cell in the current paper contains the same number, use that paper as it is and do not cut it further.
  2. Otherwise, divide the current paper into 9 equal square pieces, and repeat the same process for each piece.

After all cutting is complete, find the number of papers made only of -1, the number of papers made only of 0, and the number of papers made only of 1.

Input

The first line contains N. N is at least 1, at most 3^7, and is a power of 3.

The next N lines contain the matrix representing the paper. Each line contains N integers separated by spaces, and each integer is one of -1, 0, and 1.

Output

On the first line, print the number of papers made only of -1.

On the second line, print the number of papers made only of 0.

On the third line, print the number of papers made only of 1.