#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 50010;
int q, n, m, x[N], y[N];
string s[N];
void in() {}
void solve() {
  cin >> q;
  while (q--) {
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    int ans = inf;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      for (int j = 0; j < m; j++) {
        if (s[i][j] == '.') {
          x[i]++;
          y[j]++;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int sum = x[i] + y[j];
        if (s[i][j] == '.') {
          sum--;
        }
        ans = min(ans, sum);
      }
    }
    cout << ans << endl;
  }
}
void out() {}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(NULL);
  in();
  solve();
  out();
  return 0;
}
