#include <bits/stdc++.h>
using namespace std;
int main() {
  long int a;
  cin >> a;
  for (long int i = 0; i < a; i++) {
    long int m, n;
    cin >> m >> n;
    char A[m][n];
    for (long int j = 0; j < m; j++) {
      for (long int k = 0; k < n; k++) cin >> A[j][k];
    }
    long int colu[n], row[m], count1, count2;
    for (int j = 0; j < n; j++) {
      count1 = 0;
      for (int k = 0; k < m; k++) {
        if (A[k][j] == '.') count1++;
      }
      colu[j] = count1;
    }
    for (int j = 0; j < m; j++) {
      count2 = 0;
      for (int k = 0; k < n; k++) {
        if (A[j][k] == '.') count2++;
      }
      row[j] = count2;
    }
    long int sum = m + n + 1, sum1;
    long int count;
    for (long int j = 0; j < m; j++) {
      for (long int k = 0; k < n; k++) {
        if (A[j][k] == '.')
          sum1 = row[j] + colu[k] - 1;
        else
          sum1 = row[j] + colu[k];
        sum = sum1 < sum ? sum1 : sum;
        if (sum == 0) break;
      }
      if (sum == 0) break;
    }
    cout << sum << endl;
  }
}
