#include <bits/stdc++.h>
using namespace std;
signed main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, m;
    cin >> n >> m;
    char v[n][m];
    for (int j = 0; j < n; j++)
      for (int l = 0; l < m; l++) cin >> v[j][l];
    int nd[n], fuck[m];
    for (int j = 0; j < n; j++) {
      nd[j] = m;
      for (int l = 0; l < m; l++) nd[j] -= (v[j][l] == '*');
    }
    for (int j = 0; j < m; j++) {
      fuck[j] = n;
      for (int l = 0; l < n; l++) fuck[j] -= (v[l][j] == '*');
    }
    int ans = n + m;
    for (int j = 0; j < n; j++)
      for (int l = 0; l < m; l++) {
        ans = min(ans, nd[j] + fuck[l] - (v[j][l] == '.'));
      }
    cout << ans << '\n';
  }
  return 0;
}
