#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 100010;
int T, n, m;
char s[800010];
int g[800010], up[800010], lf[800010];
template <typename T>
void gi(T &x) {
  x = 0;
  register char c = getchar(), pre = 0;
  for (; c < '0' || c > '9'; pre = c, c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10ll + (c ^ 48);
  if (pre == '-') x = -x;
}
inline int add(const int &x, const int &y) {
  return x + y < mod ? x + y : x + y - mod;
}
inline int sub(const int &x, const int &y) {
  return x - y < 0 ? x - y + mod : x - y;
}
inline int mul(const int &x, const int &y) {
  return (int)((long long)x * y % mod);
}
int ksm(int x, int y = mod - 2) {
  int ss = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) ss = mul(ss, x);
  return ss;
}
int Get(int x, int y) { return (x - 1) * m + y; }
int main() {
  gi(T);
  for (; T; T--) {
    gi(n), gi(m);
    int ans = n + m - 1;
    for (int i = (1), ied = (max(n, m)); i <= ied; i++) lf[i] = up[i] = 0;
    for (int i = (1), ied = (n); i <= ied; i++) {
      scanf("%s", s + Get(i, 1));
      for (int j = (1), jed = (m); j <= jed; j++) {
        g[Get(i, j)] = (s[Get(i, j)] == '*');
        lf[i] += g[Get(i, j)];
        up[j] += g[Get(i, j)];
      }
    }
    for (int i = (1), ied = (n); i <= ied; i++)
      for (int j = (1), jed = (m); j <= jed; j++) {
        int x = n + m - up[j] - lf[i];
        if (!g[Get(i, j)]) --x;
        ans = min(ans, x);
      }
    printf("%d\n", ans);
  }
  return 0;
}
