/**
* Problem Name: Plus_of_Pluses
* Author: MJS
* Created: 16 December 2024, Monday (14:12:01)...
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define nl '\n'
struct g{
int l,r,u,d;
};
int n,m;
char c[2002][2002];
g dp[2002][2002];
void answer_to_the_question(){
cin>>n>>m;
for(int i=0;i<=n+1;i++){
for(int j=0;j<=m+1;j++){
dp[i][j].l=dp[i][j].r=dp[i][j].u=dp[i][j].d=-1;
c[i][j]='-';
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>c[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(c[i][j]=='+'){
dp[i][j].l=dp[i][j-1].l+1;
}
}
for(int j=m;j>0;j--){
if(c[i][j]=='+'){
dp[i][j].r=dp[i][j+1].r+1;
}
}
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(c[j][i]=='+'){
dp[j][i].u=dp[j-1][i].u+1;
}
}
for(int j=n;j>0;j--){
if(c[j][i]=='+'){
dp[j][i].d=dp[j+1][i].d+1;
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
int mn=min({dp[i][j].l,dp[i][j].r,dp[i][j].u,dp[i][j].d});
ans=max(ans,4*mn+1);
}
}
cout<<ans<<nl;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int test_case; cin>>test_case;
for(int MJS=1; MJS<=test_case; MJS++){
answer_to_the_question();
}
return 0;
}
// Hi..