#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long SIZE = 100000;
const int INF = 0x3f3f3f3f;
const long long ll_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acos(-1);
const long long MAXN = numeric_limits<long long>::max();
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
bool sortbysecdes(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  char c[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> c[i][j];
    }
  }
  vector<long long> row(n), col(m);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (c[i][j] == '*') row[i]++;
    }
  }
  for (long long j = 0; j < m; j++) {
    for (long long i = 0; i < n; i++) {
      if (c[i][j] == '*') col[j]++;
    }
  }
  long long min = ll_INF;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      long long time = 0;
      if (c[i][j] == '.')
        time = (m - row[i]) + (n - col[j]) - 1;
      else
        time = (m - row[i]) + (n - col[j]);
      if (time < min) {
        min = time;
      }
    }
  }
  cout << min << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
