#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000007;
const double EPS = 1e-8;
int sign(double x) { return x < -EPS ? -1 : x > EPS; }
int dbcmp(double l, double r) { return sign(l - r); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int MAXN = 5e4 + 54;
int cnt[2][MAXN];
vector<char> G[MAXN];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n, m;
    scanf("%d%d%*c", &n, &m);
    for (int(i) = 1; (i) <= (n); (i)++) {
      G[i].clear();
      cnt[0][i] = 0;
    }
    for (int(i) = 1; (i) <= (m); (i)++) {
      cnt[1][i] = 0;
    }
    for (int(i) = 1; (i) <= (n); (i)++) {
      for (int(j) = 1; (j) <= (m); (j)++) {
        char ch = getchar();
        if (ch == '*') {
          cnt[0][i]++;
          cnt[1][j]++;
        }
        G[i].push_back(ch);
      }
      getchar();
    }
    int ans = n + m + 20;
    for (int(i) = 1; (i) <= (n); (i)++) {
      for (int(j) = 1; (j) <= (m); (j)++) {
        ans = min(ans, n + m - cnt[0][i] - cnt[1][j] - (G[i][j - 1] == '.'));
      }
    }
    printf("%d\n", ans);
  }
}
