#include <bits/stdc++.h>
using namespace std;
const int NMAX = 5e4 + 5;
int T, N, M;
int dx[NMAX], dy[NMAX];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> T;
  while (T--) {
    cin >> N >> M;
    int ans = 2e9;
    for (int i = 1; i <= N; ++i) dx[i] = 0;
    for (int i = 1; i <= M; ++i) dy[i] = 0;
    char S[N + 1][M + 1];
    for (int i = 1; i <= N; ++i) {
      cin >> (S[i] + 1);
      for (int j = 1; j <= M; ++j)
        if (S[i][j] == '*') {
          ++dx[i];
          ++dy[j];
        }
    }
    for (int i = 1; i <= N; ++i)
      for (int j = 1; j <= M; ++j)
        ans = min(ans, N + M - 1 - (dx[i] + dy[j] - (S[i][j] == '*')));
    cout << ans << '\n';
  }
  return 0;
}
