#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int MOD = 1e9 + 7;
const long long oo = 1e9 + 7;
long long GCD(long long a, long long b) { return !b ? a : GCD(b, a % b); }
int main() {
  int q, n, m;
  cin >> q;
  while (q-- && cin >> n >> m) {
    vector<string> grid(n);
    vector<int> r(n), c(m);
    for (long long i = 0; i < n; i++) {
      cin >> grid[i];
      for (long long j = 0; j < m; j++)
        if (grid[i][j] == '*') ++r[i], ++c[j];
    }
    int ans = oo;
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++)
        ans = min(ans, n + m - r[i] - c[j] - 1 + (grid[i][j] == '*'));
    printf("%d\n", ans);
  }
  return 0;
}
