#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    char a[n][m];
    long long x[n], y[m];
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++) cin >> a[i][j];
    for (long long i = 0; i < n; i++) {
      long long count = 0;
      for (long long j = 0; j < m; j++) {
        if (a[i][j] == '.') count++;
      }
      x[i] = count;
    }
    for (long long j = 0; j < m; j++) {
      long long count = 0;
      for (long long i = 0; i < n; i++) {
        if (a[i][j] == '.') count++;
      }
      y[j] = count;
    }
    long long res = LLONG_MAX;
    long long e = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        e = 0;
        if (a[i][j] == '.') e = 1;
        res = min(res, x[i] + y[j] - e);
      }
    }
    cout << res << endl;
  }
  return 0;
}
