#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
const double pi = 2 * acos(0.0);
int main() {
  int t;
  scanf("%d", &(t));
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<vector<bool>> grid(n);
    int minrow = 1e6, mincol = 1e6;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        char c;
        scanf(" %c", &c);
        if (c == '*')
          grid[i].push_back(1);
        else
          grid[i].push_back(0);
      }
    }
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < m; j++) {
        if (!grid[i][j]) cnt++;
      }
      minrow = min(minrow, cnt);
    }
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (!grid[j][i]) cnt++;
      }
      mincol = min(mincol, cnt);
    }
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      vector<int> emp;
      for (int j = 0; j < m; j++) {
        if (!grid[i][j]) cnt++, emp.push_back(j);
      }
      if (cnt == minrow && cnt != 0) {
        for (auto& e : emp) {
          int cnt = 0;
          for (int k = 0; k < n; k++) {
            if (!grid[k][e] && k != i) cnt++;
          }
          mincol = min(mincol, cnt);
        }
      }
    }
    printf("%d\n", mincol + minrow);
  }
  return 0;
}
