#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long t;
	cin >> t;
	while(t--)
	{
		long long n;
		cin >> n;
		string a[n];
		for(long long i=0;i<n;i++)
		{
			cin >> a[i];
		}
		for(long long i=0;i<10;i++)
		{
			long long ans=0;
			std::vector<pair<long long,long long> > x,y;
			for(long long j=0;j<n;j++)
			{
				for(long long k=0;k<n;k++)
				{
					if(a[j][k]==((char)i+'0'))
					{
						x.push_back(make_pair(j,k) );
						y.push_back(make_pair(k,j) );
					}
				}
			}
			sort(x.begin(), x.end());
			sort(y.begin(), y.end());
			for(long long k=0;k<x.size();k++)
				{
					long long x1=x[0].first,y1=x[0].second,x2=x[k].first,y2=x[k].second;
					ans=max(ans,abs(x1-x2)*max(max(y1,n-y1-1),max(y2,n-y2-1)));
					ans=max(ans,abs(y1-y2)*max(max(x1,n-x1-1),max(x2,n-x2-1)));
				}
			for(long long k=0;k<x.size();k++)
				{
					long long x1=x[k].first,y1=x[k].second,x2=x[x.size()-1].first,y2=x[x.size()-1].second;
					ans=max(ans,abs(x1-x2)*max(max(y1,n-y1-1),max(y2,n-y2-1)));
					ans=max(ans,abs(y1-y2)*max(max(x1,n-x1-1),max(x2,n-x2-1)));
				}
			for(long long k=0;k<y.size();k++)
				{
					long long y1=y[0].first,x1=y[0].second,y2=y[k].first,x2=y[k].second;
					ans=max(ans,abs(x1-x2)*max(max(y1,n-y1-1),max(y2,n-y2-1)));
					ans=max(ans,abs(y1-y2)*max(max(x1,n-x1-1),max(x2,n-x2-1)));
				}
			for(long long k=0;k<y.size();k++)
				{
					long long y1=y[k].first,x1=y[k].second,y2=y[y.size()-1].first,x2=y[y.size()-1].second;
					ans=max(ans,abs(x1-x2)*max(max(y1,n-y1-1),max(y2,n-y2-1)));
					ans=max(ans,abs(y1-y2)*max(max(x1,n-x1-1),max(x2,n-x2-1)));
				}
			//}
			cout << ans << " ";
		}
		cout << endl;
	}
}