#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[500005];
int arc[500005];
int ch[500005];
char s[400005];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n * m; ++i) ch[i] = arr[i] = arc[i] = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%s", s);
      for (int j = 0; j < m; ++j) {
        if (s[j] == '*') {
          ch[i * m + j + 1] = 1;
          arr[i]++;
          arc[j + 1]++;
        }
      }
    }
    int ans = n + m - 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 1; j <= m; ++j) {
        ans = min(ans, n + m - 1 - arr[i] - arc[j] + (int)ch[i * m + j]);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
