#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<char> > vc(n, vector<char>(m, '.'));
    vector<long long> vc1(n, 0), vc2(m, 0);
    for (int i = 0; i < n; ++i) {
      int count_3 = 0;
      for (int j = 0; j < m; ++j) {
        cin >> vc[i][j];
        if (vc[i][j] == '.') ++count_3;
      }
      vc1[i] = count_3;
    }
    for (int j = 0; j < m; ++j) {
      int count_2 = 0;
      for (int i = 0; i < n; ++i) {
        if (vc[i][j] == '.') ++count_2;
      }
      vc2[j] = count_2;
    }
    long long mmin = 1e12 + 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (vc[i][j] == '.')
          mmin = min(mmin, vc1[i] + vc2[j] - 1);
        else
          mmin = min(mmin, vc1[i] + vc2[j]);
      }
    }
    cout << mmin << '\n';
  }
}
