/**
* author: Binoy Barman
* created: 2024-12-10 16:48:55
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
Too_Many_Jobs {
int n, m;
cin >> n >> m;
vector<vector<char>> g(n + 2, vector<char>(m + 2, '#'));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> g[i][j];
}
}
vector<vector<array<int, 4>>> a(n + 2, vector<array<int, 4>>(m + 2, {0, 0, 0, 0}));
for (int i = 1; i <= n; i++) {
int l = 1, r = 1;
while(l <= m) {
while(l <= m && g[i][l] == '-') l++;
if(l > m) continue;
r = l;
while(r < m && g[i][r + 1] == '+') r++;
for (int j = l; j <= r; j++) {
a[i][j][0] = l;
a[i][j][1] = r;
}
l = r + 1;
}
}
for (int j = 1; j <= m; j++) {
int l = 1, r = 1;
while(l <= n) {
while(l <= n && g[l][j] == '-') l++;
if(l > n) continue;
r = l;
while(r < n && g[r + 1][j] == '+') r++;
for (int i = l; i <= r; i++) {
a[i][j][2] = l;
a[i][j][3] = r;
}
l = r + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) if(g[i][j] == '+') {
auto c = a[i][j];
int cur = min({j - c[0], c[1] - j, i - c[2], c[3] - i});
ans = max(ans, 1 + cur * 4);
}
}
cout << ans << nl;
}
return 0;
}