#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int N = 50005;
int row[N], column[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    cin >> n >> m;
    fill(row, row + n, 0);
    fill(column, column + m, 0);
    vector<vector<bool> > graph;
    graph.resize(n, vector<bool>(m));
    for (int i = 0; i <= n - 1; ++i) {
      for (int j = 0; j <= m - 1; ++j) {
        char c;
        cin >> c;
        graph[i][j] = (c == '*');
        if (c == '.') {
          row[i]++;
          column[j]++;
        }
      }
    }
    int ans = (int)(1e9 + 7);
    for (int i = 0; i <= n - 1; ++i) {
      for (int j = 0; j <= m - 1; ++j) {
        ans = min(ans, row[i] + column[j] - (!graph[i][j]));
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
