#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
char a[400005];
int row[400005];
int col[400005];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    cin >> n >> m;
    int ans = inf;
    for (int i = 0; i < n; i++) {
      row[i] = 0;
      for (int j = m * i; j < m * (i + 1); j++) {
        cin >> a[j];
        if (a[j] == '.') row[i]++;
      }
    }
    for (int i = 0; i < m; i++) {
      col[i] = 0;
      for (int j = i; j < n * m; j += m)
        if (a[j] == '.') col[i]++;
    }
    int k = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (a[i * m + j] == '*')
          ans = min(ans, row[i] + col[j]);
        else
          ans = min(ans, row[i] + col[j] - 1);
    cout << ans << endl;
  }
  return 0;
}
