#include <bits/stdc++.h>
using namespace std;
int q, n, m, ans;
vector<string> mp;
int main() {
  scanf("%d\n", &q);
  while (q--) {
    scanf("%d %d\n", &n, &m);
    string tmp;
    vector<int> xSum, ySum;
    mp.clear();
    for (int i = 0; i < n; i++) {
      getline(cin, tmp);
      mp.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < m; j++) {
        if (mp[i][j] == '*') cnt++;
      }
      xSum.push_back(cnt);
    }
    for (int j = 0; j < m; j++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (mp[i][j] == '*') cnt++;
      }
      ySum.push_back(cnt);
    }
    ans = 987654321;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int cnt = xSum[i] + ySum[j];
        if (mp[i][j] == '*') cnt--;
        ans = min(ans, n + m - 1 - cnt);
      }
    }
    printf("%d\n", ans);
  }
}
