#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char s[n + 2][m + 2];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> s[i][j];
    int s1[n + 2], s2[m + 2];
    for (int i = 1; i <= n; i++) s1[i] = 0;
    for (int i = 1; i <= m; i++) s2[i] = 0;
    int maxs1 = 0, maxs2 = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++)
        if (s[i][j] == '*') s1[i]++;
      maxs1 = max(maxs1, s1[i]);
    }
    for (int j = 1; j <= m; j++) {
      int check = 0;
      for (int i = 1; i <= n; i++) {
        if (s[i][j] == '*') s2[j]++;
        if (s1[i] == maxs1 && s[i][j] == '.') {
          check = 1;
        }
      }
      if (check == 1) s2[j]++;
      maxs2 = max(maxs2, s2[j]);
    }
    cout << n + m - maxs1 - maxs2 << endl;
  }
}
