#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
const int sz = 2005 ;
char grid[sz][sz] ;
int n , m , leftToRight[sz][sz] , rightToLeft[sz][sz] , topToDown[sz][sz] , downToTop[sz][sz];
void preCalc() {
// Left to Right
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
if(grid[i][j] != '+') leftToRight[i][j] = 0 ;
else {
if(j == 0) leftToRight[i][j] = 1 ;
else {
leftToRight[i][j] = 1 + leftToRight[i][j - 1] ;
}
}
}
}
// Right to Left
for(int i = 0 ; i < n ; i++){
for(int j = m - 1 ; j >= 0 ; j--){
if(grid[i][j] != '+') rightToLeft[i][j] = 0 ;
else {
if(j == (m - 1)) rightToLeft[i][j] = 1 ;
else {
rightToLeft[i][j] = 1 + rightToLeft[i][j + 1] ;
}
}
}
}
// Top to Down
for(int j = 0 ; j < m ; j++) {
for(int i = 0 ; i < n ; i++){
if(grid[i][j] != '+') topToDown[i][j] = 0 ;
else {
if(i == 0) topToDown[i][j] = 1 ;
else {
topToDown[i][j] = topToDown[i - 1][j] + 1 ;
}
}
}
}
// Down to Top
for(int j = 0 ; j < m ; j++) {
for(int i = n - 1 ; i >= 0 ; i--){
if(grid[i][j] != '+') downToTop[i][j] = 0 ;
else {
if(i == (n - 1)) downToTop[i][j] = 1 ;
else {
downToTop[i][j] = downToTop[i + 1][j] + 1 ;
}
}
}
}
// for(int i = 0 ; i < n ; i++){
// for(int j = 0 ; j < m ; j++){
// cout << i << " " << j << " --> " << leftToRight[i][j] << " and " << rightToLeft[i][j] << " " << topToDown[i][j] << " " << downToTop[i][j] << endl ;
// }
// }
}
void solve()
{
int Ans = 0; cin >> n >> m ;
for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < m ; j++) {
cin >> grid[i][j] ;
leftToRight[i][j] = rightToLeft[i][j] = topToDown[i][j] = downToTop[i][j] = 0 ;
}
preCalc() ;
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++){
if(grid[i][j] == '+') {
int totPlus = min({leftToRight[i][j] - 1 , rightToLeft[i][j] - 1 , topToDown[i][j] - 1 , downToTop[i][j] - 1 }) * 4 ;
Ans = max(Ans , 1 + totPlus ) ;
}
}
}
cout << Ans << "\n" ;
}
int main()
{
__Heart__
int t ; cin >> t ; while(t--) solve() ;
}