#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const int N = 1e5 + 5, inf = 1e9 + 5;
long long add(long long x, long long y) {
  x += y;
  if (x >= MOD) return x - MOD;
  return x;
}
long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) return x + MOD;
  return x;
}
long long mult(long long x, long long y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<int> row_sum(n), col_sum(m);
    vector<vector<bool>> a(n, vector<bool>(m));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        char c;
        cin >> c;
        row_sum[i] += c == '*';
        col_sum[j] += c == '*';
        a[i][j] = c == '*';
      }
    }
    int ans = inf;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        ans = min(ans, n - row_sum[i] + m - col_sum[j] - (!a[i][j]));
      }
    }
    cout << ans << endl;
  }
}
