#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q, n, m, count, ans, an;
  char c;
  scanf("%lld", &q);
  for (long long t = 0; t < q; t++) {
    scanf("%lld", &n), scanf("%lld", &m);
    scanf("%c", &c);
    long long ar[m + 1], br[n + 1];
    char array[n + 1][m + 1];
    for (long long a = 0; a < m; a++) {
      ar[a] = 0;
    }
    for (long long a = 0; a < n; a++) {
      br[a] = 0;
    }
    for (long long i = 0; i < n; i++) {
      count = 0;
      for (long long j = 0; j < m; j++) {
        scanf("%c", &c);
        array[i][j] = c;
        if (c == '.') {
          count++;
          ar[j]++;
          br[i]++;
        }
      }
      scanf("%c", &c);
    }
    ans = 100000000000000;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        an = br[i] + ar[j];
        if (array[i][j] == '.') an--;
        ans = min(an, ans);
      }
    }
    printf("%lld", ans);
    printf("\n");
  }
}
