#include <bits/stdc++.h>
using namespace std;
int T, n, m;
const int maxn = 5e4 + 233;
string s[maxn];
int x[maxn], y[maxn];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> T;
  while (T--) {
    cin >> n >> m;
    for (int i = 0; i <= n; i++) {
      x[i] = 0;
    }
    for (int j = 0; j <= m; j++) {
      y[j] = 0;
    }
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        x[i] += s[i][j] == '*';
      }
    }
    for (int j = 0; j < m; j++) {
      for (int i = 0; i < n; i++) {
        y[j] += s[i][j] == '*';
      }
    }
    int res = 1e9;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int tmp = n + m - 1 - x[i] - y[j];
        if (s[i][j] == '*') tmp++;
        res = min(res, tmp);
      }
    }
    cout << res << '\n';
  }
  return 0;
}
