#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define print(v) for(auto data : v) cout << data << " "; cout << endl;
using namespace std;
void solve()
{
int n, m;
cin >> n >> m;
char mat[n+1][m+1];
bool isFound = false;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> mat[i][j];
if(mat[i][j] == '+') isFound = true;
}
}
if(isFound == false)
{
cout << 0 << endl; return;
}
int mx = 1;
int mx_val = n + m - 1;
for (int i = 2; i < n; i++)
{
for (int j = 2; j < m; j++)
{
int temp = 1;
int cnt = 0;
if(mat[i][j] == '+')
{
while (i-1-cnt >= 1 && i-1-cnt <= n &&
i+1+cnt >= 1 && i+1+cnt <= n &&
j-1-cnt >= 1 && j-1-cnt <= m &&
j+1+cnt >= 1 && j+1+cnt <= m
&& mat[i][j-1-cnt] == '+' && mat[i][j+1+cnt] == '+' &&
mat[i-1-cnt][j] == '+' && mat[i+1+cnt][j] == '+')
{
cnt++, temp += 4;
}
mx = max(mx, temp);
if(mx == mx_val)
{
cout << mx << endl; return;
}
}
}
}
cout << mx << endl;
}
int main ()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int t; cin >> t;
// int t = 1;
while (t--) solve();
return 0;
}