#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  int r, c;
  int max_r, max_c, mc, mr;
  int counter_c = 0;
  int counter_r = 0;
  char s[4000001];
  cin >> q;
  vector<int> result(q);
  for (int i = 0; i < q; ++i) {
    cin >> r >> c;
    vector<int> rows(r, 0);
    vector<int> columns(c, 0);
    vector<int> ro(r, 0);
    vector<int> co(c, 0);
    vector<vector<bool> > v(r, vector<bool>(c, 0));
    max_c = 0;
    max_r = 0;
    mc = 0;
    mr = 0;
    for (int j = 0; j < r; ++j) {
      cin >> s;
      for (int i = 0; i < c; ++i) {
        if (s[i] == '*') {
          rows[j]++;
          columns[i]++;
          v[j][i] = 1;
          if (rows[j] > max_r) {
            counter_r = -1;
            max_r = rows[j];
            mr = j;
          }
          if (columns[i] > max_c) {
            counter_c = -1;
            max_c = columns[i];
            mc = i;
          }
          if (rows[j] == max_r) {
            ro[++counter_r] = j;
          }
          if (columns[i] == max_c) {
            co[++counter_c] = i;
          }
        }
      }
    }
    result[i] = r - max_r + c - max_c;
    int x = i;
    bool flag = 0;
    for (int i = 0; i <= counter_c; ++i) {
      int c = co[i];
      for (int j = 0; j <= counter_r; ++j) {
        int r = ro[j];
        if (v[r][c] == 0) {
          result[x]--;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
  }
  for (int i = 0; i < q; ++i) {
    cout << result[i] << endl;
  }
  return 0;
}
