#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T div_floor(T a, T b) {
  if (b < 0) a *= -1, b *= -1;
  return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
  if (b < 0) a *= -1, b *= -1;
  return a > 0 ? (a - 1) / b + 1 : a / b;
}
constexpr long long mod = 1000000007;
constexpr long long INF = mod * mod;
constexpr int MAX = 200010;
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  char c[n][m];
  for (int((i)) = (int)(0); ((i)) < (int)((n)); ++((i)))
    for (int((j)) = (int)(0); ((j)) < (int)((m)); ++((j)))
      scanf(" %c", &c[i][j]);
  int cnt_row[n], cnt_col[m];
  for (int((i)) = (int)(0); ((i)) < (int)((n)); ++((i))) {
    cnt_row[i] = 0;
    for (int((j)) = (int)(0); ((j)) < (int)((m)); ++((j)))
      cnt_row[i] += (c[i][j] == '*');
  }
  for (int((j)) = (int)(0); ((j)) < (int)((m)); ++((j))) {
    cnt_col[j] = 0;
    for (int((i)) = (int)(0); ((i)) < (int)((n)); ++((i)))
      cnt_col[j] += (c[i][j] == '*');
  }
  int ans = mod;
  for (int((i)) = (int)(0); ((i)) < (int)((n)); ++((i)))
    for (int((j)) = (int)(0); ((j)) < (int)((m)); ++((j))) {
      int tmp = n - cnt_row[i] + m - cnt_col[j];
      tmp -= (c[i][j] == '.');
      chmin(ans, tmp);
    }
  printf("%d\n", ans);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int((tt)) = (int)(0); ((tt)) < (int)((t)); ++((tt))) solve();
}
