#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 1000004;
long long p, q, x, l, ans = 0, r, y, z, i, j, n, m, t, d, cnt = 0, sum = 0;
string s;
string give;
long long int mn = 0x3f3f3f3f, len, mx = 0;
const long long int N = 10010;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    char a[n][m];
    long long int r[n], c[m];
    for (long long int i = 0; i < n; i++)
      for (long long int j = 0; j < m; j++) cin >> a[i][j];
    for (long long int i = 0; i < n; i++) {
      long long int cn = 0;
      for (long long int j = 0; j < m; j++) {
        cn += (a[i][j] == '*');
      }
      r[i] = cn;
    }
    for (long long int j = 0; j < m; j++) {
      long long int cn = 0;
      for (long long int i = 0; i < n; i++) {
        cn += (a[i][j] == '*');
      }
      c[j] = cn;
    }
    long long int ans = 1241511354;
    for (long long int i = 0; i < n; i++)
      for (long long int j = 0; j < m; j++)
        ans = min(n + m - (r[i] + c[j]) - (a[i][j] == '.'), ans);
    cout << ans << endl;
  }
  return 0;
}
