#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout << #a << " : " << a << endl;
void solve(){
int n, m; cin >> n >> m;
char s[n + 5][m + 5];
int l [n + 5][m + 5];
int r [n + 5][m + 5];
int t [n + 5][m + 5];
int b [n + 5][m + 5];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> s[i][j];
}
}
for(int i = 1; i <= n; i++){
int cnt = 0;
for(int j = 1; j <= m; j++){
l[i][j] = cnt;
if(s[i][j] == '+'){
cnt++;
}
else{
cnt = 0;
}
}
cnt = 0;
for(int j = m; j > 0; j--){
r[i][j] = cnt;
if(s[i][j] == '+'){
cnt++;
}
else{
cnt = 0;
}
}
}
for(int j = 1; j <= m; j++){
int cnt = 0;
for(int i = 1; i <= n; i++){
t[i][j]= cnt;
if(s[i][j]== '+'){
cnt++;
}
else{
cnt = 0;
}
}
cnt = 0;
for(int i = m; i > 0; i--){
b[i][j]= cnt;
if(s[i][j]== '+'){
cnt++;
}
else{
cnt = 0;
}
}
}
ll mx = 0;
// for(int i = 1; i <= n; i++){
// for(int j = 1; j <= m; j++){
// cout << l[i][j] << ' ' << r[i][j] << ' ' << t[i][j] << ' ' << b[i][j] << endl;
// }
// cout << endl;
// }
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(s[i][j] == '+'){
int tmp = min({l[i][j], r[i][j], t[i][j], b[i][j]});
mx = max(mx, (1LL * 4 * tmp) + 1);
}
}
}
cout << mx << '\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc = 1, cs = 0;
cin >> tc;
while(tc--){
//cout << "Case # " << ++cs << ": " ;
solve();
}
}