Triangles

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

문제

Gildong has a square board consisting of nn rows and nn columns of square cells, each consisting of a single digit (from 00 to 99). The cell at the jj-th column of the ii-th row can be represented as (i,j)(i,j), and the length of the side of each cell is 11. Gildong likes big things, so for each digit dd, he wants to find a triangle such that:

  • Each vertex of the triangle is in the center of a cell.
  • The digit of every vertex of the triangle is dd.
  • At least one side of the triangle is parallel to one of the sides of the board. You may assume that a side of length 00 is parallel to both sides of the board.
  • The area of the triangle is maximized.

Of course, he can’t just be happy with finding these triangles as is. Therefore, for each digit dd, he’s going to change the digit of exactly one cell of the board to dd, then find such a triangle. He changes it back to its original digit after he is done with each digit. Find the maximum area of the triangle he can make for each digit.

Note that he can put multiple vertices of the triangle on the same cell, and the triangle can be a degenerate triangle; i.e. the area of the triangle can be 00. Also, note that he is allowed to change the digit of a cell from dd to dd.

입력

Each test contains one or more test cases. The first line contains the number of test cases tt (1t10001\le t\le 1000).

The first line of each test case contains one integer nn (1n20001\le n\le 2000) --- the number of rows and columns of the board.

The next nn lines of each test case each contain a string of nn digits without spaces. The jj-th digit of the ii-th line is the digit of the cell at (i,j)(i,j). Each digit is one of the characters from 00 to 99.

It is guaranteed that the sum of n2n^2 in all test cases doesn’t exceed 41064\cdot 10^6.

출력

For each test case, print one line with 1010 integers. The ii-th integer is the maximum area of triangle Gildong can make when d=i1d=i-1, multiplied by 22.

힌트

In the first case, for d=0d=0, no matter which cell he chooses to use, the triangle with vertices at (1,1)(1,1), (1,3)(1,3), and (3,1)(3,1) is the biggest triangle with area of 222=2\cfrac{2\cdot 2}{2} =2. Since we should print it multiplied by 22, the answer for d=0d=0 is 44.

For d=1d=1, Gildong can change the digit of the cell at (1,3)(1,3) into 11, making a triangle with vertices on all three 11’s that has an area of 22.

For d=2d=2, Gildong can change the digit of one of the following six cells into 22 to make a triangle with an area of 12\cfrac{1}{2}: (1,1)(1,1), (1,2)(1,2), (1,3)(1,3), (3,1)(3,1), (3,2)(3,2), and (3,3)(3,3).

For the remaining digits (from 33 to 99), the cell Gildong chooses to change will be the only cell that contains that digit. Therefore the triangle will always be a degenerate triangle with an area of 00.

In the third case, for d=4d=4, note that the triangle will be bigger than the answer if Gildong changes the digit of the cell at (1,4)(1,4) and use it along with the cells at (2,1)(2,1) and (4,3)(4,3), but this is invalid because it violates the condition that at least one side of the triangle must be parallel to one of the sides of the board.