#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, i, j;
    cin >> n >> m;
    char a[n + 1][m + 1];
    for (i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (j = 0; j < m; j++) a[i][j] = s[j];
    }
    vector<long long> row, col;
    for (i = 0; i < n; i++) {
      long long cnt = 0;
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.') cnt++;
      }
      row.push_back(cnt);
    }
    for (j = 0; j < m; j++) {
      long long cnt = 0;
      for (i = 0; i < n; i++) {
        if (a[i][j] == '.') cnt++;
      }
      col.push_back(cnt);
    }
    long long ans = INT_MAX, rowans, colans;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        long long curr = row[i] + col[j];
        if (a[i][j] == '.') curr--;
        if (curr < ans) {
          ans = curr;
          rowans = i;
          colans = j;
        }
      }
    }
    cout << ans << endl;
  }
}
