#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int q;
  cin >> q;
  while (q--) {
    long long int n, m;
    cin >> n >> m;
    char s[n][m];
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> s[i][j];
      }
    }
    long long int r[n], c[m];
    for (long long int i = 0; i < n; i++) {
      long long int temp = 0;
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == '*') {
          temp++;
        }
      }
      r[i] = temp;
    }
    for (long long int i = 0; i < m; i++) {
      long long int temp = 0;
      for (long long int j = 0; j < n; j++) {
        if (s[j][i] == '*') {
          temp++;
        }
      }
      c[i] = temp;
    }
    long long int ans = INT_MAX;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        long long int temp;
        temp = n + m - r[i] - c[j];
        if (s[i][j] == '.') {
          temp--;
        }
        ans = min(ans, temp);
      }
    }
    cout << ans << endl;
  }
}
