#include <bits/stdc++.h>
using namespace std;
string A[50000];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int row[50000] = {0}, col[50000] = {0}, mn = INT_MAX, i, j, n, m;
    cin >> n >> m;
    for (i = 0; i < n; i++) cin >> A[i];
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++)
        if (A[i][j] == '*') {
          row[i]++;
          col[j]++;
        }
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) {
        if (A[i][j] == '*')
          mn = min(mn, m - row[i] + n - col[j]);
        else
          mn = min(mn, m - row[i] + n - col[j] - 1);
      }
    cout << mn << endl;
  }
}
