#include <bits/stdc++.h>
using namespace std;
long long nChooseR(int n, int k);
long long gcd(long long a, long long b);
vector<string> split(string target, char c);
bool isPrime(long long g);
long long n, k, r, l, t, x, y, m;
long long ans;
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<string> s(n);
    vector<int> a(n), b(m);
    ans = 1e9;
    for (int i = 0; i < (int)(n); i++) cin >> s[i];
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(m); j++)
        a[i] += (s[i][j] == '.'), b[j] += (s[i][j] == '.');
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(m); j++) {
        if (s[i][j] == '.')
          ans = min((int)ans, a[i] + b[j] - 1);
        else
          ans = min((int)ans, a[i] + b[j]);
      }
    cout << ans << "\n";
  }
  return 0;
}
long long nChooseR(int n, int k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  long long result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
vector<string> split(string target, char c) {
  string d = "";
  vector<string> arr;
  for (auto n : target) {
    if (n != c)
      d += n;
    else if (d != "")
      arr.push_back(d), d = "";
  }
  if (d != "") arr.push_back(d), d = "";
  return arr;
}
bool isPrime(long long g) {
  if ((g % 2 == 0 && g > 2) || g == 1) return 0;
  for (int i = 3; i * i <= g; i += 2)
    if (g % i == 0) return 0;
  return 1;
}
