#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n, m, x, T, g1, g2;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> m >> n;
    int u = n + m;
    int A[m][n];
    int B[m], C[n];
    for (int j = 0; j < m; j++) B[j] = 0;
    for (int j = 0; j < n; j++) C[j] = 0;
    char g;
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < n; k++) {
        cin >> g;
        if (g == '*')
          A[j][k] = 1;
        else
          A[j][k] = 0;
        B[j] += A[j][k];
        C[k] += A[j][k];
      }
    }
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < n; k++) {
        u = min(u, m - C[k] + n - B[j] + A[j][k] - 1);
      }
    }
    cout << u << endl;
  }
}
