#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 7;
string str[maxn];
int x[maxn], y[maxn];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
      x[i] = 0;
    }
    for (int i = 0; i < m; i++) {
      y[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> str[i];
      for (int j = 0; j < m; j++) {
        if (str[i][j] == '*') {
          x[i]++;
          y[j]++;
        }
      }
    }
    int ans = -1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        ans = max(ans, x[i] + y[j] - (str[i][j] == '*'));
      }
    }
    cout << n + m - 1 - ans << endl;
  }
  return 0;
}
