#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  int n, m;
  int num;
  int k;
  for (int i = 0; i < q; i++) {
    cin >> n >> m;
    char pole[n][m];
    int s[n];
    int p[m];
    for (int i = 0; i < n; i++) s[i] = 0;
    for (int i = 0; i < m; i++) p[i] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> pole[i][j];
        if (pole[i][j] == '.') {
          s[i]++;
          p[j]++;
        }
      }
    }
    num = n + m - 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        k = s[i] + p[j];
        if (pole[i][j] == '.') k--;
        if (k < num) num = k;
      }
    }
    cout << num << endl;
  }
  return 0;
}
