#include <bits/stdc++.h>
using namespace std;
string c[50050];
int ib[50050], jb[50050];
int main() {
  int T, ans;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    ans = 0x3f3f3f3f;
    memset(ib, 0, sizeof(ib));
    memset(jb, 0, sizeof(jb));
    for (int i = 0; i < n; i++) {
      c[i].clear();
      cin >> c[i];
      for (int j = 0; j < m; j++) {
        if (c[i][j] == '.') {
          ib[i] += 1;
          jb[j] += 1;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (c[i][j] == '*') {
          ans = min(ans, ib[i] + jb[j]);
        } else {
          ans = min(ans, ib[i] + jb[j] - 1);
          if (ans == -1) {
            cout << endl << ib[i] << jb[j] << i << j << endl;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
