#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const double PI = acos(-1);
string dest[50005];
int a[50005];
int b[50005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  cin >> T;
  while (T--) {
    int n, m, col = 0, lin = 0, t = 0, k = 0;
    int cntt = 0, cntk = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
      cin >> dest[i];
    }
    for (int i = 0; i < n; ++i) {
      int ans = 0;
      for (int j = 0; j < m; ++j) {
        if (dest[i][j] == '*') ans += 1;
      }
      if (ans > col) {
        t = i;
        col = ans;
      }
    }
    for (int i = 0; i < n; ++i) {
      int ans = 0;
      for (int j = 0; j < m; ++j) {
        if (dest[i][j] == '*') ans += 1;
      }
      if (ans == col) {
        a[cntt++] = i;
      }
    }
    for (int i = 0; i < m; ++i) {
      int ans = 0;
      for (int j = 0; j < n; ++j) {
        if (dest[j][i] == '*') ans += 1;
      }
      if (ans > lin) {
        k = i;
        lin = ans;
      }
    }
    for (int i = 0; i < m; ++i) {
      int ans = 0;
      for (int j = 0; j < n; ++j) {
        if (dest[j][i] == '*') ans += 1;
      }
      if (ans == lin) {
        b[cntk++] = i;
      }
    }
    for (int i = 0; i < cntt; ++i) {
      int flag = 0;
      for (int j = 0; j < cntk; ++j) {
        if (dest[a[i]][b[j]] == '.') {
          n -= 1;
          flag = 1;
          break;
        }
      }
      if (flag == 1) break;
    }
    cout << m - col + n - lin << endl;
  }
  return 0;
}
