#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl << "\n"
#define yes << "YES\n"
#define no << "NO\n"
#define sp " "
int n, k;
const int N = 2000 + 5, K = 2000 + 5;
char a[N][K];
int clk(int x, int y)
{
int val = 1000000, mn = 0;
int left = 0, right = 0, up = 0, down = 0;
for (int i = y - 1; i >= 0; i--)
{
if (a[x][i] == '+')
{
left++;
}
else
{
break;
}
}
for (int i = y + 1; i < k; i++)
{
if (a[x][i] == '+')
{
right++;
}
else
{
break;
}
}
for (int i = x- 1; i >= 0; i--)
{
if (a[i][y] == '+')
{
up++;
}
else
{
break;
}
}
for (int i = y + 1; i < n; i++)
{
if (a[i][y] == '+')
{
down++;
}
else
{
break;
}
}
//cout << "left:"<<left << " right: "<< right << " up:" << up << " down:" << down nl;
val=min(val,min(left,right));
return (val * 4) + 1;
}
void solve()
{
cin >> n >> k;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
cin >> a[i][j];
}
}
int mx = 0, cnt = 0;
// clk(1,1);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
if (a[i][j] == '+'){
mx = max(mx, clk(i,j));}
// cout<<mx;
}
}
cout << mx nl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
for (ll i = 0; i < t; i++)
solve();
return 0;
}