#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n,m; cin>>n>>m;
char a[n][m];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
int ans = 0;
int p = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]=='+')
{
// cout<<a[i][j]<<' ';
p = 1;
int l = 1, r = 512;
while(l<=r)
{
int mid = (l+r)/2;
int cnt =0;
for(int k=j-1;k>=0;k--)
{
if(a[i][k]!='+') break;
else cnt++;
}
if(cnt<mid)
{
r = mid-1;
continue;
}
cnt = 0;
for(int k=j+1;k<m;k++)
{
if(a[i][k]!='+') break;
else cnt++;
}
if(cnt<mid)
{
r = mid-1;
continue;
}
cnt = 0;
for(int k=i-1;k>=0;k--)
{
if(a[k][j]!='+') break;
else cnt++;
}
if(cnt<mid)
{
r = mid-1;
continue;
}
cnt = 0;
for(int k=i+1;k<n;k++)
{
if(a[k][j]!='+') break;
else cnt++;
}
if(cnt<mid)
{
r = mid-1;
continue;
}
l = mid+1;
int nw = (4LL*mid) + 1;
ans = max(ans,nw);
}
}
}
}
cout<<max(ans,p)<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc;
cin>>tc;
while(tc--)
{
solve();
}
return 0;
}