#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e4 + 10;
vector<int> dict[maxn];
int dp1[maxn], dp2[maxn];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    cin >> n >> m;
    string s;
    for (int i = 0; i < n; ++i) {
      cin >> s;
      for (int j = 0; j < s.size(); ++j) {
        if (dict[i].size() > j)
          dict[i][j] = (s[j] == '*' ? 1 : 0);
        else
          dict[i].push_back(s[j] == '*' ? 1 : 0);
      }
    }
    for (int i = 0; i < n; ++i) {
      int tmp = 0;
      for (int j = 0; j < m; ++j) {
        if (dict[i][j] == 0) tmp++;
      }
      dp1[i] = tmp;
    }
    for (int j = 0; j < m; ++j) {
      int tmp = 0;
      for (int i = 0; i < n; ++i) {
        if (dict[i][j] == 0) tmp++;
      }
      dp2[j] = tmp;
    }
    int ans = 1e9;
    for (int i = 0; i < n; ++i) {
      int tmp;
      for (int j = 0; j < m; ++j) {
        tmp = dp1[i] + dp2[j];
        if (dict[i][j] == 0) tmp--;
        ans = min(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
