#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  int g[n + 1][m + 1], r[n + 1], c[m + 1];
  memset(g, 0, sizeof g);
  memset(r, 0, sizeof r);
  memset(c, 0, sizeof c);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      g[i][j] = x == '*';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      r[i] += g[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      c[i] += g[j][i];
    }
  }
  int ans = 1e9 + 5;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int nx = m - r[i];
      int ny = n - c[j];
      if (g[i][j] == 0) {
        int need = nx + ny - 1;
        ans = min(ans, need);
      } else {
        int need = nx + ny;
        ans = min(ans, need);
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}
