#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int i, j, n, m, q;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    char a[n][m];
    int row_coloured[n], column_coloured[m];
    for (i = 0; i < n; i++) row_coloured[i] = 0;
    for (i = 0; i < m; i++) column_coloured[i] = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) {
        cin >> a[i][j];
        column_coloured[j] += (a[i][j] == '*');
        row_coloured[i] += (a[i][j] == '*');
      }
    int max_coloured = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) {
        if (a[i][j] == '*')
          max_coloured =
              max(max_coloured, row_coloured[i] + column_coloured[j] - 1);
        else
          max_coloured =
              max(max_coloured, row_coloured[i] + column_coloured[j]);
      }
    cout << (m + n - 1 - max_coloured) << '\n';
  }
  return 0;
}
