#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
void fast_in_out() {
  std::ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
}
int dx[] = {0, 1, 1, 1, -1, 1, 0, 0};
int dy[] = {0, 0, -1, 1, 0, 0, -1, 1};
const long double eps = 1e-9;
const int mod = 1e9 + 7;
const int N = 5e4 + 10, M = 22;
string grid[N];
int col[N], row[N];
int main() {
  fast_in_out();
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    memset(col, 0, m * sizeof col[0]);
    for (int i = 0; i < n; i++) {
      cin >> grid[i];
      row[i] = 0;
      for (int j = 0; j < m; j++) {
        row[i] += (grid[i][j] == '*');
        col[j] += (grid[i][j] == '*');
      }
    }
    int mx = 1e9;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int x = row[i], y = col[j];
        int sum = x + y;
        if (grid[i][j] == '*') sum--;
        mx = min(mx, n + m - 1 - sum);
      }
    }
    cout << mx << '\n';
  }
  return 0;
}
