#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 20;
const int M = 5e4 + 20;
char a[N];
int q = 0;
int n, m;
int h[M], l[M];
int main() {
  cin >> q;
  while (q--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) h[i] = 0;
    for (int j = 1; j <= m; j++) l[j] = 0;
    for (int i = 1; i <= n; i++) {
      getchar();
      for (int j = 1; j <= m; j++) {
        scanf("%c", &a[i * m + j]);
        if (a[i * m + j] == '*') {
          h[i]++;
          l[j]++;
        }
      }
    }
    int ans = 1e9;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        int x = m - h[i] + n - l[j];
        if (a[i * m + j] == '.') x--;
        if (x < ans) ans = x;
        if (x == 0) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
