#include <bits/stdc++.h>
using namespace std;
#define inf 1013161010
#define mod 1000000007
#define mod1 998244353
#define ll long long
#define lf long double
#define sz(x) ((int)x.size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,a,b) for(ll i=a;i<=b;i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){ stringstream ss; ss<< number; return ss.str();}
template <typename T>
void print1(T arr[], int n) { rep(i, n) { cout << arr[i] << " "; } cout << endl; }
template <typename T, size_t N, size_t M>
void print2(T (&arr)[N][M], int n, int m) { rep(i, n) { rep(j, m) { cout << arr[i][j] << " "; } cout << endl; } cout << endl; }
template <typename T>
void print1v(const vector<T>& vec, int n) { for (int i = 0; i < n && i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
template <typename T>
void print2v(const vector<vector<T>>& vec, int n, int m) { for (int i = 0; i < n && i < vec.size(); i++) { for (int j = 0; j < m && j < vec[i].size(); j++) { cout << vec[i][j] << " "; } cout << endl; } cout << endl;}
const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;
ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
ll fast_pow(ll a,ll m, ll mode) { if(m==0) return 1; else if(m==1) return a; ll h=fast_pow(a,m/2,mode); if(m%2==0) return ((h*h)%mode); else return ((((h*h)%mode)*a)%mode);}
ll mmi(ll b, ll mode){return fast_pow(b, mode-2, mode);}
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char arr[2005][2005];
int v1[2005][2005], v2[2005][2005], v3[2005][2005], v4[2005][2005];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
ll n, m, k, x, ans=0;
cin >> n >> m;
rep(i, n) {
rep(j, m) {
cin >> arr[i][j];
v1[i][j] = 0;
v2[i][j] = 0;
v3[i][j] = 0;
v4[i][j] = 0;
}
}
for (int i = 0; i < n; i++ ) {
if (arr[i][0] == '+') {
v1[i][0] = 1;
}
for (int j = 1; j < m; j++) {
if (arr[i][j] == '+') {
v1[i][j] = v1[i][j-1] + 1;
} else {
v1[i][j] = 0;
}
}
}
for (int i = 0; i < n; i++ ) {
if (arr[i][m-1] == '+') {
v2[i][m-1] = 1;
}
for (int j = m-2; j >= 0; j--) {
if (arr[i][j] == '+') {
v2[i][j] = v2[i][j+1] + 1;
} else {
v2[i][j] = 0;
}
}
}
for (int j = 0; j < m; j++ ) {
if (arr[0][j] == '+') {
v3[0][j] = 1;
}
for (int i = 1; i < n; i++) {
if (arr[i][j] == '+') {
v3[i][j] = v3[i-1][j] + 1;
} else {
v3[i][j] = 0;
}
}
}
for (int j = 0; j < m; j++ ) {
if (arr[n-1][j] == '+') {
v4[n-1][j] = 1;
}
for (int i = n-2; i >= 0; i--) {
if (arr[i][j] == '+') {
v4[i][j] = v4[i+1][j] + 1;
} else {
v4[i][j] = 0;
}
}
}
ans = 0;
rep(i, n) {
rep(j, m) {
if (arr[i][j] == '+') {
ll side = min(v1[i][j], min(v2[i][j], min(v3[i][j], v4[i][j]))) - 1;
ans = max(side*4+1, ans);
}
}
}
cout << ans << endl;
}
return 0;
}