#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int INF = (int)1e18;
void fileio() {}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<char> > v(n, vector<char>(m));
  vector<long long> v1(n, 0), v2(m, 0);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> v[i][j];
      if (v[i][j] == '.') {
        v1[i]++;
        v2[j]++;
      }
    }
  }
  long long ans = INT_MAX;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (v[i][j] == '.') {
        ans = min(ans, v1[i] + v2[j] - 1);
      } else {
        ans = min(ans, v1[i] + v2[j]);
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  fileio;
  int t;
  cin >> t;
  while (t--) solve();
}
