#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 10;
long long a[maxn];
long long b[maxn];
string ss[maxn];
int32_t main() {
  long long T;
  cin >> T;
  while (T--) {
    long long n, m;
    cin >> n >> m;
    for (long long i = 0; i < n; i++) cin >> ss[i];
    long long temp1 = 0;
    long long temp2 = 0;
    for (long long i = 0; i < n; i++) {
      long long t = 0;
      for (long long j = 0; j < m; j++) {
        if (ss[i][j] == '*') t++;
      }
      a[i] = t;
    }
    for (long long i = 0; i < m; i++) {
      long long t = 0;
      for (long long j = 0; j < n; j++) {
        if (ss[j][i] == '*') t++;
      }
      b[i] = t;
    }
    long long ans = 1e9 + 10;
    for (long long i = 0; i <= n; i++) {
      for (long long j = 0; j <= m; j++) {
        if (a[i] == m && b[j] == n)
          ans = 0;
        else {
          ans = min(ans, n - a[i] + m - b[j] - 1 + (ss[i][j] == '*'));
        }
      }
    }
    for (long long i = 0; i < n; i++) a[i] = 0;
    for (long long i = 0; i < m; i++) b[i] = 0;
    cout << ans << endl;
  }
}
