#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  long long a[n];
  long long b[m];
  for (long long i = 0; i < n; i++) {
    long long cnt = 0;
    for (long long j = 0; j < m; j++)
      if (s[i][j] == '.') cnt++;
    a[i] = cnt;
  }
  for (long long i = 0; i < m; i++) {
    long long cnt = 0;
    for (long long j = 0; j < n; j++)
      if (s[j][i] == '.') cnt++;
    b[i] = cnt;
  }
  long long ans = INT_MAX;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      long long temp = a[i] + b[j];
      if (s[i][j] == '.') temp--;
      ans = min(ans, temp);
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
