#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long q, n, m;
  string grid[50005];
  cin >> q;
  while (q--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> grid[i];
    }
    map<int, int> ro, co;
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < m; k++) {
        if (grid[i][k] == '*') {
          ro[i]++;
          co[k]++;
        }
      }
    }
    long long mn = LONG_LONG_MAX;
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < m; k++) {
        long long total = ro[i] + co[k];
        if (total > (n + m - 1)) {
          mn = 0;
        } else {
          if (grid[i][k] == '*') {
            total--;
          }
          long long need = (n + m - 1) - total;
          mn = min(mn, need);
        }
      }
    }
    cout << mn << endl;
  }
  return 0;
}
