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