#include <bits/stdc++.h>
using namespace std;
int nc[50001];
int mc[50001];
map<pair<int, int>, bool> a;
pair<int, int> P;
int main() {
  int Q;
  scanf("%d", &Q);
  int i, j;
  while (Q--) {
    int n, m;
    scanf("%d %d\n", &n, &m);
    for (i = 0; i < n; i++) nc[i] = 0;
    for (i = 0; i < m; i++) mc[i] = 0;
    a.clear();
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        char x;
        scanf("%c", &x);
        if (x == '*') {
          P.first = i;
          P.second = j;
          a[P] = 1;
          nc[i]++;
          mc[j]++;
        }
      }
      scanf("\n");
    }
    int ans = 9999999;
    int count;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        count = (n + m) - (nc[i] + mc[j]);
        P.first = i;
        P.second = j;
        if (!a[P] && count != 0) count--;
        ans = min(count, ans);
      }
    }
    printf("%d\n", ans);
  }
}
