#include <bits/stdc++.h>
using namespace std;
int row[100010], col[100010];
vector<char> mat[100010];
int main() {
  int t, n, m, mx, mxRow, mxCol, ans;
  char ch;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    mx = max(n, m);
    for (int i = 0; i <= mx; i++) {
      row[i] = 0, col[i] = 0;
      ;
      mat[i].clear();
    }
    mxRow = 0, mxCol = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> ch;
        mat[i].push_back(ch);
        if (ch == '*') {
          row[i]++;
          col[j]++;
        }
        if (row[i] >= mxRow) {
          mxRow = row[i];
        }
        if (col[j] >= mxCol) {
          mxCol = col[j];
        }
      }
    }
    ans = (n - mxRow) + (m - mxCol);
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (row[i] != mxRow || col[j] != mxCol) continue;
        if (mat[i][j] == '.') {
          ans--;
          break;
        }
      }
      if (j != m) break;
    }
    cout << ans << endl;
  }
  return 0;
}
