#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
string a[N];
int r[N], c[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; i++) r[i] = 0;
    for (int j = 0; j <= m; j++) c[j] = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (a[i][j] == '.') r[i]++, c[j]++;
    int ans = 1e9 + 7;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        int cur = r[i] + c[j];
        if (a[i][j] == '.') cur--;
        ans = min(ans, cur);
      }
    cout << ans << "\n";
  }
}
