All Submissions


Problem Statement

Given a grid of cells where each cell contains a digit, find the largest square in this grid that contains the same digit in all of its corner cells. Find the number of cells in the square. Note that a single cell is also a square.

Input

First line of input contains T,the number of test cases.
For each case, the size of the string array is given and following it is the input string array.

Output

Print the largest number of cells in the square.

Constraints

Data will contain between 1 and 50 elements, inclusive.
The given grid is rectangular.
Each element of data will contain between 1 and 50 digits ('0'-'9'), inclusive.
All elements of data will have the same length.

Sample Input


3
3
13032
32034
33234
2
56
78
1
0123456789


Sample Output


9
1
1


Explanation

In the first test case,the largest square is the 3x3 square that contains the digit '3' in each of its corner cells.

Problem Setter: Anjali Singh

Languages: C,C++,C#,Java,JavaScript,Pascal,Perl,PHP,Python,Ruby

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0