#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> ndp(n), mdp(m);
  vector<string> items(n);
  for (int i = 0; i < n; i++) {
    cin >> items[i];
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      if (items[i][j] == '*') {
        cnt++;
      }
    }
    ndp[i] = cnt;
  }
  for (int j = 0; j < m; j++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (items[i][j] == '*') {
        cnt++;
      }
    }
    mdp[j] = cnt;
  }
  int need = n + m - 1;
  int res = 1e8;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int ase = ndp[i] + mdp[j];
      if (items[i][j] == '*') {
        ase--;
      }
      ase = need - ase;
      res = min(res, ase);
    }
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
