#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define srt(v) sort(v.begin(), v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define pb push_back
void solve(){
int n, m;
cin >> n >> m;
char grid[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin >> grid[i][j];
}
}
int sumr=0, r=0;
int sumc=0, c=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(grid[i][j]=='+') r++;
}
sumr=max(sumr, r);
r=0;
}
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
if(grid[j][i]=='+') c++;
}
sumc=max(sumc, c);
c=0;
}
if(sumc+sumr-1>=1){
cout << sumr+sumc-1 << endl;
}
else{
cout << 0 << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while(t--){
solve();
}
}