#include <bits/stdc++.h>
using namespace std;
int a[500005];
int b[500005];
vector<char> x[500005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    fill(a + 1, a + 1 + n, 0);
    fill(b + 1, b + 1 + m, 0);
    for (int i = 1; i <= n; i++) x[i].resize(m + 1);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        cin >> x[i][j];
        if (x[i][j] == '*') {
          a[i]++;
          b[j]++;
        }
      }
    int res = INT_MAX;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        res = min(res, n + m - 1 - a[i] - b[j] + (x[i][j] == '*'));
      }
    cout << res << '\n';
  }
}
