#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;
vector<pair<ll, ll>> v;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
cin >> a[i][j];
if (a[i][j] == '+')
v.push_back({i, j});
}
}
ll mx = 0, cnt = 0;
for (auto i : v)
{
mx = max(mx, clk(i.first, i.second));
}
// // clk(2,3);
// int i = 0, j = 0;
// while (i < n)
// {
// if (a[i][j] == '+')
// {
// }
// if (j == k - 1)
// {
// i++, j = 0;
// }
// else
// j++;
// }
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;
}