#include <bits/stdc++.h>
using namespace std;
const int md = (int)1e9 + 7;
const int siz = 100005;
long long arr[siz];
string s[siz];
long long n, m, k, l, t;
long long arx[siz], ary[siz];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      arx[i] = 0;
      cin >> s[i];
      for (int j = 0; j < m; j++) {
        if (s[i][j] == '*') arx[i]++;
      }
    }
    for (int i = 0; i < m; i++) {
      ary[i] = 0;
      for (int j = 0; j < n; j++) {
        if (s[j][i] == '*') ary[i]++;
      }
    }
    int maxx = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (s[j][i] == '.' && arx[j] + ary[i] + 1 > maxx)
          maxx = arx[j] + ary[i] + 1;
        else if (arx[j] + ary[i] > maxx)
          maxx = arx[j] + ary[i];
      }
    }
    cout << n + m - maxx << '\n';
  }
}
