#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 ;
int countPlusLeft(int i , int j){
int cnt = 0 ;
while(j >= 0) {
if(grid[i][j] != '+') break ;
else cnt++ ;
j-- ;
}
return cnt ;
}
int countPlusRight(int i , int j){
int cnt = 0 ;
while(j < m) {
if(grid[i][j] != '+') break ;
else cnt++ ;
j++ ;
}
return cnt ;
}
int countPlusTop(int i , int j){
int cnt = 0 ;
while(i >= 0) {
if(grid[i][j] != '+') break ;
else cnt++ ;
i-- ;
}
return cnt ;
}
int countPlusDown(int i , int j){
int cnt = 0 ;
while(i < n) {
if(grid[i][j] != '+') break ;
else cnt++ ;
i++ ;
}
return cnt ;
}
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] ;
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++){
if(grid[i][j] == '+') {
int totPlus = min({countPlusLeft(i , j - 1) , countPlusRight(i , j + 1) , countPlusDown(i + 1 , j) , countPlusTop(i - 1 , j)}) * 4 ;
Ans = max(Ans , 1 + totPlus ) ;
}
}
}
cout << Ans << "\n" ;
}
int main()
{
__Heart__
int t ; cin >> t ; while(t--) solve() ;
}