#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using o_set = tree<T, null_type, std::less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
void solve() {
int n, m;
cin >> n >> m;
char g[n + 5][m + 5];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) cin >> g[i][j];
}
int rs[n + 5][m + 5], rr[n + 5][m + 5], cs[n + 5][m + 5], cr[n + 5][m + 5];
memset(rs, 0, sizeof(rs));
memset(rr, 0, sizeof(rr));
memset(cs, 0, sizeof(cs));
memset(cr, 0,sizeof(cr));
//for (int i = 0; i)
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) cout << cr[i][j] << " \n"[j == m];
// }
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if(g[i][j] == '+') rs[i][j] = rs[i][j - 1] + 1;
else rs[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = m; j >= 1; j--) {
if(g[i][j] == '+') rr[i][j] = rr[i][j + 1] + 1;
else rr[i][j] = 0;
}
}
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if(g[j][i] == '+') cs[j][i] = cs[j - 1][i] + 1;
else cs[j][i] = 0;
}
}
for (int i = 1; i <= m; i++) {
for (int j = n; j >= 1; j--) {
if(g[j][i] == '+') cr[j][i] = cr[j + 1][i] + 1;
else cr[j][i] = 0;
}
}
int ans = 0;
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) cout << rs[i][j] << " \n"[j == m];
// }
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) cout << rr[i][j] << " \n"[j == m];
// }
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) cout << cs[i][j] << " \n"[j == m];
// }
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) cout << cr[i][j] << " \n"[j == m];
// }
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if(g[i][j] == '+') {
//cout << "d";
int mn = min({rs[i][j - 1], rr[i][j + 1], cs[i - 1][j], cr[i + 1][j]});
ans = max(ans, (4 * mn) + 1);
}
}
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin>>t;
for(int tc = 1; tc <= t; tc++) {
// cout<<"Case "<<tc<<":";
solve();
}
}