#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;
int n, m;
const int N = 1e4 + 5;
char mat[N][N];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> mat[i][j];
}
}
int mx = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; 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);
}
}
}
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;
}