#include<bits/stdc++.h>
using namespace std;
const int N = 2010;
int a[N];
char g[N][N];
struct point{
	int x;
	int y;
};
vector<point>v;
int n;
int get(point a,point b)
{
	int res=0;
	int x1=a.x;
	int x2=b.x;
	int y1=a.y;
	int y2=b.y;
	x1++,x2++,y1++,y2++;
	int maxv1=max(max(x1-1,n-x1),max(x2-1,n-x2));
	int maxv2=max(max(y1-1,n-y1),max(y2-1,n-y2));
	res=max(maxv1*abs(y1-y2),maxv2*abs(x1-x2));
	return res;
}
signed main()
{
	int t;
	cin>>t;
	while(t--)
	{
		v.clear();
		cin>>n;
		for(int i=0;i<n;i++)
		{
			scanf("%s",g[i]);
		}
		for(int i=0;i<=9;i++)
		{
			int res=0;
			v.clear();
			for(int j=0;j<n;j++)
			{
			for(int k=0;k<n;k++)
			if(g[j][k]==(char)(i+'0'))
			{
				v.push_back({j,k});
				break;
			}
			for(int k=n-1;k>=0;k--)
			if(g[j][k]==(char)(i+'0'))
			{
				point tt=v[v.size()-1];
				if(tt.y==k)	break;
				v.push_back({j,k});
				break;
			}
			}
			for(int j=0;j<v.size();j++)
			for(int k=j+1;k<v.size();k++)
			{
				res=max(res,get(v[j],v[k]));
			}
			cout<<res<<" ";
		}
		cout<<endl;
	}
	return 0;
}
			 	     	 				    		 	   	 		