#include <bits/stdc++.h>
using namespace std;
inline long long add(long long x, long long y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
  return x;
}
inline long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += 1000000007;
  return x;
}
inline long long mul(long long x, long long y) {
  return ((x % 1000000007) * (y % 1000000007)) % 1000000007;
}
inline long long pwr(long long a, long long b) {
  long long x = 1LL;
  while (b) {
    if (b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
bool CHK(long long n) {
  if (n == 1) return 0;
  if (n == 2 or n == 3) return 1;
  if (n % 2 == 0 or n % 3 == 0) return 0;
  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 or n % (i + 2) == 0) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long q = 0;
  cin >> q;
  while (q--) {
    long long n, m;
    cin >> n >> m;
    long long a[n + 1][m + 1];
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        char c;
        cin >> c;
        if (c == '*')
          a[i][j] = 1;
        else
          a[i][j] = 0;
      }
    }
    long long mxr = 0;
    long long mxc = 0;
    long long row = -1, col = -1;
    map<long long, long long> we;
    long long res = numeric_limits<long long>::max();
    for (long long i = 0; i < n; i++) {
      long long s = 0;
      for (long long j = 0; j < m; j++) {
        s += a[i][j];
      }
      we[i] = m - s;
    }
    for (long long i = 0; i < m; i++) {
      long long s = 0;
      for (long long j = 0; j < n; j++) {
        s += a[j][i];
      }
      for (long long j = 0; j < n; j++) {
        if (a[j][i] == 0) {
          res = min(res, n - s - 1 + we[j]);
        } else {
          res = min(res, n - s + we[j]);
        }
      }
    }
    cout << res << "\n";
    memset(a, 0, sizeof a);
  }
  return 0;
}
