#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int n, m;
    cin >> n >> m;
    vector<string> table(n);
    vector<int> row(n);
    vector<int> column(m);
    for (int j = 0; j < n; j++) {
      row[j] = 0;
    }
    for (int j = 0; j < m; j++) {
      column[j] = 0;
    }
    for (int j = 0; j < n; j++) {
      string s;
      cin >> s;
      table[j] = s;
    }
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        if (table[j][k] == '*') {
          row[j]++;
          column[k]++;
        }
      }
    }
    int ans = 1000000;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        int temp = 0;
        if (table[j][k] == '.') {
          temp = m + n - row[j] - column[k] - 1;
          if (ans > temp) ans = temp;
        } else {
          temp = m + n - row[j] - column[k];
          if (ans > temp) ans = temp;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
