#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int> rows(n), cols(m);
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      if (v[i][j] == '*') {
        cnt++;
      }
    }
    rows[i] = cnt;
  }
  for (int i = 0; i < m; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (v[j][i] == '*') {
        cnt++;
      }
    }
    cols[i] = cnt;
  }
  int t = INT_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == '*') {
        t = min(t, n - rows[i] + m - cols[j]);
      } else {
        t = min(t, n - rows[i] + m - cols[j] - 1);
      }
    }
  }
  cout << t << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
