#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    int a[n];
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a[i] = x;
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i+1]) < max || max == -1){
            max = abs(a[i]-a[i+1]);
            cout << max << endl;
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index+1 << ' ' << index+2;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <int> len;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        len.push_back(x);
    }
    int dif = -1,index1 = 0,index2 = 0;
    for (int i =0;i<n;i++){
        for(int j = i+1;j<n;j++){
            if (abs(len[i]-len[j]) < dif || dif == -1){
                dif = abs(len[i]-len[j]);
                index1 = i;
                index2 = j;
            }
        }
    }
    cout << index1+1 << ' ' << index2+1;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    int a[n];
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a[i] = x;
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i-1]) < max || max == -1){
            max = abs(a[i]-a[i-1]);
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index << ' ' << index + 1;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    vector <int> a;
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i+1]) < max || max == -1){
            max = abs(a[i]-a[i+1]);
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index+1 << ' ' << index+2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v,v1;
int main()
{
int n,mn=10000,m,k;
cin>>n;
for(int i=0;i<n;i++)
{
	int h;
	cin>>h;
	v.push_back(h);
}
v1=v;
sort(v.begin(),v.end());
for(int i=0;i<n-1;i++)
{
	if(mn>v[i+1]-v[i])
	{
		m=i;
	}

}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m])
{
	cout<<i+1<<" ";
	k=i;
	v.erase(v.begin()+i);
	break;
}
}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m+1])
{
	if(k>i)
	cout<<i+1;
	else cout<<i+2;
	return 0;
}
}
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    int n,m,ans=10000,p1=0,p2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
     int h;
     cin>>h;
     v.push_back(h);
    }
    v.push_back(v[0]);
    for(int i=0;i<n+1;i++)
    {
        if(abs(v[i]-v[i-1])<ans)
        {
            p1=i;
            p2=i-1;
            ans=abs(v[i]-v[i-1]);
        }
        }
    cout<<p1+1<<" "<<p2+1;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    int n,m,ans=10000,p1=0,p2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
     int h;
     cin>>h;
     v.push_back(h);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
        if(abs(v[i]-v[j])<ans)
        {
            p1=i;
            p2=j;
            ans=abs(v[i]-v[j]);
            break;
        }
        }
    }
    cout<<p1+1<<" "<<p2+1;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v,v1;
int main()
{
int n,mn=10000,m,k;
cin>>n;
for(int i=0;i<n;i++)
{
    int h;
    cin>>h;
    v.push_back(h);
}
v1=v;
sort(v.begin(),v.end());
for(int i=0;i<n-1;i++)
{
    if(mn>v[i+1]-v[i])
    {
        m=i;
        mn=v[i+1]-v[i];
    }

}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m])
{
    cout<<i+1<<" ";
    k=i;
    v1.erase(v1.begin()+i);
    break;
}
}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m+1])
{
    if(k>=i)
    cout<<i+1;
    else cout<<i+2;
    return 0;
}
}
}
//10 10 12 13 15
//10 12 13 15 10


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    int n,m,ans=10000,p1=0,p2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
     int h;
     cin>>h;
     v.push_back(h);
    }
    v.push_back(v[0]);
    for(int i=0;i<n+1;i++)
    {
        if(abs(v[i]-v[i-1])<ans)
        {
            p1=i;
            p2=i-1;
            ans=abs(v[i]-v[i-1]);
        }
        }
        if(p1==n)
    cout<<1<<" "<<p2;
    else cout<<p1<<" "<<p2;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    int n,m,ans=10000,p1=0,p2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
     int h;
     cin>>h;
     v.push_back(h);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
        if(abs(v[i]-v[j])<ans)
        {
            p1=i;
            p2=j;
            ans=abs(v[i]-v[j]);
        }
        }
    }
    cout<<p1+1<<" "<<p2+1;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v,v1;
int main()
{
int n,mn=10000,m,k;
cin>>n;
for(int i=0;i<n;i++)
{
    int h;
    cin>>h;
    v.push_back(h);
}
v1=v;
sort(v.begin(),v.end());
for(int i=0;i<n-1;i++)
{
    if(mn>v[i+1]-v[i])
    {
        m=i;
        mn=v[i+1]-v[i];
    }

}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m])
{
    cout<<i+1<<" ";
    k=i;
    v1.erase(v1.begin()+i);
    break;
}
}
for(int i=0;i<n;i++)
{
if(v1[i]==v[m+1])
{
    if(k>i)
    cout<<i+1;
    else cout<<i+2;
    return 0;
}
}
}
//10 10 12 13 15
//10 12 13 15 10


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    int n,m,ans=10000,p1=0,p2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
     int h;
     cin>>h;
     v.push_back(h);
    }
    v.push_back(v[0]);
    for(int i=0;i<n+1;i++)
    {
        if(abs(v[i]-v[i-1])<ans)
        {
            p1=i;
            p2=i-1;
            ans=abs(v[i]-v[i-1]);
        }
        }
        if(p1==n)
    cout<<1<<" "<<p2+1;
    else cout<<p1+1<<" "<<p2+1;
}


#include<stdio.h>

int main()
{
    int n,i,t,min=1000,z;
    int a[101];
    scanf("%d ",&n);
    for (i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for (i=1;i<=n;i++)
        {
                      if (i==n) t=a[i]-a[1];
                     else t=a[i]-a[i+1];
                     if (t<0) t=-t;
                     if (t<min)
                        {
                               z=i;
                               min=t;
                        }
        }
    if (z==n) printf("%d 1",n);
    else printf("%d %d",z,z+1);

    return 0;
}


#include<stdio.h>

int main()
  {
    int n,i,j,min,k,cs1,cs2;
    int a[100];

    scanf("%d",&n);

    for(i=0;i<n;i++)
      scanf("%d",&a[i]);

    min=2000;
    for(i=0;i<n-1;i++)
      for(j=i+1;j<n;j++)
        {
          k=a[i]-a[j];
          if(k<0)
            k=-k;
          if(min>k)
            {
              min=k;
              cs1=i+1;
              cs2=j+1;
            }
        }

    if(a[cs1]<a[cs2])
      printf("%d %d",cs1,cs2);
    else
      printf("%d %d",cs2,cs1);
    return 0;
  }


#include<stdio.h>

int n,a[100],m,k,i,min,t;
void docfile()
{

     scanf("%d",&n);
     for(i=0;i<n;i++) scanf("%d",&a[i]);

}
void xuly()
{
       m=1;
       k=n;
       min=((a[n-1]-a[0]));
       if(min<0)
          min=-min;
       for(i=0;i<n-1;i++)
       {
                  t=(a[i]-a[i+1]);
                  if(t<0)
                    t=-t;
                  if(t>=min)
                  {
                            min=min;
                            m=m;
                            k=k;
                  }
                  else {min=t; m=i+1; k=i+2;};
       }
}
void xuatfile()
{

     printf("%d",m);
     printf(" %d",k);

}
int main()
{
    docfile();
    xuly();
    xuatfile();
    return 0;
}


#include<stdio.h>

int main ()
{

	long n,i,j,min,tri,hieu,bien,tuyet,tru;
	int a[1000];

	scanf("%ld",&n);
	for(i=0;i<=n-1;i++)
	  scanf("%d",&a[i]);

	for(j=1;j<=n-1;j++)
	  {
	    hieu=a[j+1]-a[j];
		if(hieu<=0)
		  tri=-hieu;
		else
		  tri=hieu;

		min=1;
		if(min>=tri)
	      min=tri;
	    else
	      min=min;

	    tru=a[n]-a[1];
		if(tru<=0)
		  tuyet=tru;
		else
		  tuyet=tru;

		if(min<tuyet)
		  {
		    min=min;
		    printf("%d %d",j,j+1);
		    break;
		  }
		else
		  {
		    min=tuyet;
		    printf("%d %d",n,j);
		    break;
		  }

	  }

	return 0;
}


#include <iostream>
using namespace std;
int n,t,minn,a[110];
int main(){
	int n;
	cin>>n;
	for (int i=0; i<n; ++i){
		cin>>a[i];
	}
	minn = -1;
	for (int i=0; i<n; ++i){
		for (int j=i+1; j<n; ++j){
			t = a[i] - a[j];
			if (t<0){
				t = -t;
			}
			if (t<minn||minn==-1){
				minn = t;
			}
		}
	}
	cout<<minn;
}


#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int n,t,minn,f,s,a[110];
int main(){
	int n;
	cin>>n;
	for (int c=0; c<n; ++c){
		cin>>a[c];
	}
	minn = 10000000;
	for (int i=0; i<n; ++i){
		if (i<n-1)
		{
			if(minn>abs(a[i]-a[i+1])){
				minn = abs(a[i]-a[i+1]);
				f = i+1;
				s = i+2;
			}
		}else{
			if(minn>abs(a[i]-a[0])){
				minn = abs(a[i]-a[0]);
				f = i+1;
				s = 1;
			}
		}
		}
		cout<<f<<" "<<s;
	// cin>>n;
}


#include <iostream>
using namespace std;
int n,t,min,a[110];
int main(){
    int n;
    cin>>n;
    for (int i=0; i<n; ++i){
        cin>>a[i];
    }
    min = -1;
    for (int i=0; i<n; ++i){
        for (int j=i+1; j<n; ++j){
            t = a[i] - a[j];
            if (t<0){
                t = -t;
            }
            if (t<min||min==-1){
                min = t;
            }
        }
    }
    cout<<min;
}


#include <iostream>
int n,t,min,a[110];
int main(){
	int n;
	cin>>n;
	for (int i=0; i<n; ++i){
		cin>>a[i];
	}
	min = -1;
	for (int i=0; i<n; ++i){
		for (int j=i+1; j<n; ++j){
			t = a[i] - a[j];
			if (t<0){
				t = -t;
			}
			if (t<min||min==-1){
				min = t;
			}
		}
	}
	cout<<min;
}


#include <iostream>
using namespace std;
int n,t,min,a[110];
int main(){
	int n;
	cin>>n;
	for (int i=0; i<n; ++i){
		cin>>a[i];
	}
	min = -1;
	for (int i=0; i<n; ++i){
		for (int j=i+1; j<n; ++j){
			t = a[i] - a[j];
			if (t<0){
				t = -t;
			}
			if (t<min||min==-1){
				min = t;
			}
		}
	}
	cout<<min;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int q,n,m,a,b,c,d=0,x=0,y=0,min;
	cin>>q;
	while(q--)
	{
		min=600000;
		cin>>n>>m;
		long long int arr[m+1];
		string s[n+2];
		for(int i=0;i<n;i++)
		{
			    cin>>s[i];
		}
		for(int i=0;i<m;i++)
		{
			x=0;
			for(int j=0;j<n;j++)
			{
				if(s[j][i]=='.')
				    x+=1;
			}
			arr[i]=x;
		}
		for(int i=0;i<n;i++)
		{
			x=0;
			for(int j=0;j<m;j++)
			{
				if(s[i][j]=='*')
				    x+=1;
				else
				    d=j;
			}
			for(int j=0;j<m;j++)
			{
			    a=m-x;
			    if(s[i][j]=='.')
				    b=arr[j]-1;
				else
				    b=arr[i];
				c=a+b;
				if(min>c)
				min=c;
			}
		}
		cout<<min<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int q,n,m,a,b,c,d=0,x=0,y=0,min;
	cin>>q;
	while(q--)
	{
		min=600000;
		cin>>n>>m;
		string s[n+2];
		for(int i=0;i<n;i++)
		{
			    cin>>s[i];
		}
		for(int i=0;i<n;i++)
		{
			x=0;
			for(int j=0;j<m;j++)
			{
				if(s[i][j]=='*')
				    x+=1;
				    d=i;
			}
			a=m-x;
		    for(int j=0;j<m;j++)
	        {
	        	y=0;
	        	for(int k=0;k<n;k++)
	        	{
				    if(s[k][j]=='*'||k==d)
				    y+=1;

				}
				b=n-y;
				c=a+b;
				if(min>c)
				min=c;
			}
		}
		cout<<min<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+10][m+10];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
			}
		}
		int best_ans = maxn;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+10][m+10];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
				else
					board[i][j] = 0;
			}
		}
		int best_ans = 2*maxn+100;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 1;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n][m];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
			}
		}
		int best_ans = maxn;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+10][m+10];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
			}
		}
		int best_ans = maxn;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j] - 1;
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+10][m+10];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
			}
		}
		int best_ans = 2*maxn+100;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const  int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+1][m+1];

		for(int i=0; i<m; i++)
			column_sum[i] = 0;
		for(int i=0; i<n; i++)
			rows_sum[i] = 0;

		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
				else
					board[i][j] = 0;
			}
		}
		int best_ans = 2*maxn+100;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const unsigned int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+10][m+10];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
				else
					borad[i][j] = 0;
			}
		}
		int best_ans = 2*maxn+100;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const bool debug = 1;
#define deb if(debug)
#define pb push_back
#define sz size()
#define mp make_pair
const  int maxn = 5 * 1e4 + 100;

int q,n,m;
int rows_sum[maxn], column_sum[maxn];
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
		bool board [n+1][m+1];
		for(int i=0; i<maxn; i++){
			column_sum[i] = 0;
			rows_sum[i] = 0;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cin>>c;
				if(c == '*'){
					board[i][j] = 1;
					column_sum[j]++;
					rows_sum[i]++;
				}
				else
					board[i][j] = 0;
			}
		}
		int best_ans = 2*maxn+100;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int candidate = n + m - rows_sum[i] - column_sum[j];
				if(!board[i][j]) candidate--;
				best_ans = min(candidate, best_ans);
			}
		}
		cout<<best_ans<<" ";
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;
const int maxn=4e5+5;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(mp[j][i]=='.')
					c[i]++;
			}
		}
		int add,minn=0x7fffffff;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
		cout<<minn<<endl;
	}
}


#include<iostream>
#include<cstring>
#include<string>
//#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=5e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	//FASTIO;
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d %d",&n,&m);
		for(int i=0;i<n;i++)
			cin>>mp[i];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add=0,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=4e5+5;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(mp[j][i]=='.')
					c[i]++;
			}
		}
		int add,minn=0x7fffffff;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
//#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=5e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	//FASTIO;
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
			cin>>mp[i];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
const int maxn=5e4+5;

string str[maxn];
int h[maxn],l[maxn];
const int inf=0x3f3f3f;
int main()
{
    int t,n,m;
    scanf("%d",&t);
    while(t--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        cin>>str[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(str[i][j]=='.')
                h[i]++;
            }
        }
        for(int j=0;j<m;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(str[i][j]=='.')
                l[j]++;
            }
        }
        int ans=0,minn=inf;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(str[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        printf("%d\n",minn);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=5e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	FASTIO;
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
			cin>>mp[i];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=5e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	FASTIO;
	//
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=4e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=5e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	FASTIO;
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int j=0;j<m;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(mp[i][j]=='.')
					c[j]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


#include<iostream>
#include<cstring>
#include<string>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=4e5+5;
const int inf=0x7fffffff;
string mp[maxn];
int r[maxn],c[maxn];
int main()
{
	int kase;
	scanf("%d",&kase);
	while(kase--)
	{
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)
		{
			cin>>mp[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					r[i]++;
			}
		}
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(mp[j][i]=='.')
					c[i]++;
			}
		}
		int add,minn=inf;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mp[i][j]=='.')
					add=-1;
				else
					add=0;
				if(add+r[i]+c[j]<minn)
					minn=add+r[i]+c[j];
			}
		}
	printf("%d\n",minn);
	}
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    T=read();
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        n=read();m=read();
        for(int i=0;i<n;i++)
            cin>>a[i];
                for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                h[i]++;
            }
        }
        for(int j=0;j<m;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(a[i][j]=='.')
                l[j]++;
            }
        }
        /*for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }*/
        /*int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(Min>(l[j]+h[i]+ans))
                    Min=l[j]+h[i]+ans;
            }
        }*/
        int ans=0,minn=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        cout<<minn<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    T=read();
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        n=read();m=read();
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }
        int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                Min=min(Min, l[i]+h[j]+ans);
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    T=read();
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        n=read();m=read();
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }
        int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(Min>(l[j]+h[i]+ans))
                    Min=l[j]+h[i]+ans;
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    scanf("%d",&T);
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                h[i]++;
            }
        }
        for(int j=0;j<m;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(a[i][j]=='.')
                l[j]++;
            }
        }
        /*for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }*/
        /*int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(Min>(l[j]+h[i]+ans))
                    Min=l[j]+h[i]+ans;
            }
        }*/
        int ans=0,minn=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        cout<<"minn="<<minn<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    l[i]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[j]++;
            }
        }
        int ans=-1,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(h[i]+l[j]+ans<Min)
                    Min=h[i]+l[j]+ans;
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    T=read();
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        n=read();m=read();
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }
        /*int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(Min>(l[j]+h[i]+ans))
                    Min=l[j]+h[i]+ans;
            }
        }*/
        int ans=0,minn=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        cout<<minn<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    l[i]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[j]++;
            }
        }
        int ans=-1,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                Min=min(Min,l[i]+h[j]+ans);
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
/*#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    l[i]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[j]++;
            }
        }
        int ans=-1,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                Min=min(Min, l[i]+h[j]+ans);
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
const int maxn=5e4+5;
//�ǵ�Ҫ��string�����飬������char�Ķ�ά����
string str[maxn];
//���к��зֳ��������飬�Ͳ���������
int h[maxn],l[maxn];//����ÿ��ÿ���ж��ٰ׵�
const int inf=0x3f3f3f;
int main()
{
    int t,n,m;
    scanf("%d",&t);
    while(t--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        cin>>str[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(str[i][j]=='.')
                h[i]++;
            }
        }
        for(int j=0;j<m;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(str[i][j]=='.')
                l[j]++;
            }
        }
        int ans=0,minn=inf;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(str[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        printf("%d\n",minn);
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    l[i]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[j]++;
            }
        }
        int ans=-1,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                Min=min(Min, l[i]+h[j]+ans);
            }
        }
        cout<<Min<<endl;
    }
    return 0;
}


/*input
9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**
output
0
0
0
0
0
4
1
1
2
*/
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <numeric>  //accumulate()���
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
const int N=1e3+50;
const int maxn=2e5+50;
const int maxm=5e5+50;
int T,n,m;
string a[maxn];
int h[maxn],l[maxn];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    scanf("%d",&T);
    while(T--)
    {
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
            cin>>a[i];
                for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                h[i]++;
            }
        }
        for(int j=0;j<m;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(a[i][j]=='.')
                l[j]++;
            }
        }
        /*for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                    l[j]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    h[i]++;
            }
        }*/
        /*int ans=0,Min=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                    ans=-1;
                else
                    ans=0;
                if(Min>(l[j]+h[i]+ans))
                    Min=l[j]+h[i]+ans;
            }
        }*/
        int ans=0,minn=0x3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(a[i][j]=='.')
                ans=-1;
                else
                ans=0;
                if(h[i]+l[j]+ans<minn)
                minn=h[i]+l[j]+ans;

            }
        }
        cout<<minn<<endl;
    }
    return 0;
}


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	//
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[100000][100000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int counter = 0;
				for (int p = 0; p < w; p++) {
					if (arr[j][p] == '.') {
						counter++;
					}
				}
				for (int p = 0; p < l; p++) {
					if (arr[p][k] == '.' && p != j) {
						counter++;
					}
				}
				myMin = min(myMin, counter);
			}
		}
		cout << myMin << endl;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[10000][10000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int counter = 0;
				for (int p = 0; p < w; p++) {
					if (arr[j][p] == '.') {
						counter++;
					}
				}
				for (int p = 0; p < l; p++) {
					if (arr[p][k] == '.' && p != j) {
						counter++;
					}
				}
				myMin = min(myMin, counter);
			}
		}
		cout << myMin << endl;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[50000][50000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int len[50000];
		int wid[50000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[10000][10000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int len[10000];
		int wid[10000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 100000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	//
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[10000][10000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		int len[10000];
		int wid[10000];
		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = wid[j] + len[k] - 1;
				}
				else {
					spec = wid[j] + len[k];
				}
				myMin = min(myMin, spec);
			}
		}
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> w >> l;

		char arr[10000][10000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				cin >> arr[j][k];
			}
		}
		int len[10000];
		int wid[10000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 100000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[1000][1000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int len[1000];
		int wid[1000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


/*
1
5 3
...
.*.
.*.
***
.*.
*/
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    int a,b;
    cin >> a >> b;
    char arr[a][b];
    int totalPaint = 0;
    for(int i = 0; i < a; i++){
      for(int j = 0; j < b; j++){
        cin >> arr[i][j];
        if(arr[i][j] == '*'){
          totalPaint++;
        }
      }
    }
    int row[b];
    int col[a];
    for(int i = 0; i < b; i++){
      int counter = 0;
      for(int j = 0; j < a; j++){
        if(arr[j][i] == '*'){
          counter++;
        }
      }
      row[i] = counter;
    }
    for(int i = 0; i < a; i++){
      int counter = 0;
      for(int j = 0; j < b; j++){
        if(arr[i][j] == '*'){
          counter++;
        }
      }
      col[i] = counter;
    }

    int val[a][b];
    int bVal = 0;
    for(int i = 0; i < a; i++){
      for(int j = 0; j < b; j++){
        if(arr[i][j] == '*'){
          val[i][j] = col[i] + row[j] - 1;
        }else{
          val[i][j] = col[i] + row[j];
        }
        //cout << val[i][j] << " ";
        bVal = max(bVal,val[i][j]);
      }
      //cout << endl;
    }
    cout << a + b - bVal - 1 << endl;

  }

}


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[100][100];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int counter = 0;
				for (int p = 0; p < w; p++) {
					if (arr[j][p] == '.') {
						counter++;
					}
				}
				for (int p = 0; p < l; p++) {
					if (arr[p][k] == '.' && p != j) {
						counter++;
					}
				}
				myMin = min(myMin, counter);
			}
		}
		cout << myMin << endl;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[20000][20000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				cin >> arr[j][k];
			}
		}
		int len[20000];
		int wid[20000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 100000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;
	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[10000][10000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int len[10000];
		int wid[10000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < l; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;

		char arr[1000][1000];

		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int len[1000];
		int wid[1000];

		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}

		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = len[j] + wid[k] - 1;
				}
				else {
					spec = len[j] + wid[k];
				}
				myMin = min(myMin, spec);
			}
		}
		cout << myMin << endl;

	}

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[1000000][10000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int counter = 0;
				for (int p = 0; p < w; p++) {
					if (arr[j][p] == '.') {
						counter++;
					}
				}
				for (int p = 0; p < l; p++) {
					if (arr[p][k] == '.' && p != j) {
						counter++;
					}
				}
				myMin = min(myMin, counter);
			}
		}
		cout << myMin << endl;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	//
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[10000][10000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		int len[10000];
		int wid[10000];
		for (int j = 0; j < l; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[j][p] == '.') {
					counter++;
				}
			}
			len[j] = counter;
		}
		for (int j = 0; j < w; j++) {
			int counter = 0;
			for (int p = 0; p < w; p++) {
				if (arr[p][j] == '.') {
					counter++;
				}
			}
			wid[j] = counter;
		}
		myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int spec = 0;
				if (arr[j][k] == '.') {
					spec = wid[j] + len[k] - 1;
				}
				else {
					spec = wid[j] + len[k];
				}
				myMin = min(myMin, spec);
			}
		}
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// crosses.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	//
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		int w;
		cin >> l >> w;
		char arr[1000000][10000];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				//cross with j and k
				cin >> arr[j][k];
			}
		}
		int myMin = 10000;
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < w; k++) {
				int counter = 0;
				for (int p = 0; p < w; p++) {
					if (arr[j][p] == '.') {
						counter++;
					}
				}
				for (int p = 0; p < l; p++) {
					if (arr[p][k] == '.' && p != j) {
						counter++;
					}
				}
				myMin = min(myMin, counter);
			}
		}
		cout << myMin << endl;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn],c[maxn];
int n,m;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int tot=1;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[tot]=getchar();
                c[tot]=s[tot];
                tot++;
            }
        }
        int ans1=0x3f3f3f3f;
        int ans2=0x3f3f3f3f;
        int f;
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans1)
            {
                ans1=cnt;
                f=i;
            }
        }
        for(int i=1;i<=m;i++)
        {
            s[(f-1)*m+i]='*';
        }
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans2)
            {
                ans2=cnt;
            }
        }
        int ans3=ans1+ans2;
        ans1=0x3f3f3f3f;
        ans2=0x3f3f3f3f;
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(c[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans2)
            {
                ans2=cnt;
                f=j;
            }
        }
        for(int i=1;i<=n;i++)
        {
            c[(i-1)*m+f]='*';
        }
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(c[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans1)
            {
                ans1=cnt;
            }
        }
        int ans4=ans1+ans2;
        printf("%d\n",min(ans3,ans4));
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e4+5;
string s[maxn];
int n,m;
int f(int x,int y)
{
    int ans=0;
    if(s[x][y]=='.')
        ans++;
    for(int i=0;i<x;i++)
    {
        if(s[i][y]=='.')
        ans++;
    }
    for(int i=x+1;i<n;i++)
    {
        if(s[i][y]=='.')
        ans++;
    }
    for(int i=0;i<y;i++)
    {
        if(s[x][i]=='.')
        ans++;
    }
    for(int i=y+1;i<m;i++)
    {
        if(s[x][i]=='.')
        ans++;
    }
    return ans;
}
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            cin>>s[i];
        }
        int ans=0x3f3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                ans=min(ans,f(i,j));
                if(ans==0)
                {
                    i=n;break;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn];
int n,m;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int tot=0;
        memset(s,'\0',sizeof(s));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[++tot]=getchar();
            }
        }
        int ans1=0x3f3f3f3f;
        int ans2=0x3f3f3f3f;
        int f;
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans1)
            {
                ans1=cnt;
                f=i;
            }
            else if(cnt==ans1)
            {
                int aa=0,bb=0;
                for(int j=1;j<=n;j++)
                {
                    if(s[(i-1)*m+j]=='.')
                    aa++;
                }
                for(int j=1;j<=n;j++)
                {
                    if(s[(f-1)*m+j]=='.')
                    bb++;
                }
                if(aa<bb)
                {
                    f=i;
                }
            }
        }
        for(int i=1;i<=m;i++)
        {
            s[(f-1)*m+i]='*';
        }
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans2)
            {
                ans2=cnt;
            }
        }
        printf("%d\n",ans1+ans2);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn];
int n,m;
struct test
{
    int len,id;
}r[maxn],l[maxn];
int main()
{
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int tot=1;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[tot++]=getchar();
            }
        }
        int rtot=0,ltot=0;
        int rlen=0,llen=0;
        //行
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(s[(i-1)*m+j]=='*')
                cnt++;
            }
            if(cnt>rlen)
            {
                rtot=0;
                rlen=cnt;
                r[rtot].len=cnt;
                r[rtot].id=i;
                rtot++;
            }
            else if(cnt==rlen)
            {
                r[rtot].len=cnt;
                r[rtot].id=i;
                rtot++;
            }
        }
        //列
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(s[(i-1)*m+j]=='*')
                cnt++;
            }
            if(cnt>llen)
            {
                ltot=0;
                llen=cnt;
                l[ltot].len=cnt;
                l[ltot].id=j;
                ltot++;
            }
            else if(cnt==llen)
            {
                l[ltot].len=cnt;
                l[ltot].id=j;
                ltot++;
            }
        }
        int ans=0x3f3f3f3f;
        for(int i=0;i<rtot;i++)
        {
            for(int j=0;j<ltot;j++)
            {
                int tt=m-r[i].len+n-l[j].len;
                if(s[(r[i].id-1)*m+l[j].id]=='.')
                tt--;
                ans=min(ans,tt);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e4+5;
char s[maxn][maxn];
int n,m;
int f(int x,int y)
{
    int ans=0;
    if(s[x][y]=='.')
        ans++;
    for(int i=0;i<x;i++)
    {
        if(s[i][y]=='.')
        ans++;
    }
    for(int i=x+1;i<n;i++)
    {
        if(s[i][y]=='.')
        ans++;
    }
    for(int i=0;i<y;i++)
    {
        if(s[x][i]=='.')
        ans++;
    }
    for(int i=y+1;i<m;i++)
    {
        if(s[x][i]=='.')
        ans++;
    }
    return ans;
}
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            scanf("%s",s[i]);
        }
        int ans=0x3f3f3f3f;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                ans=min(ans,f(i,j));
                if(ans==0)
                {
                    i=n;break;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn];
int n,m;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int tot=0;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[++tot]=getchar();
            }
        }
        int ans1=0x3f3f3f3f;
        int ans2=0x3f3f3f3f;
        int f;
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans1)
            {
                ans1=cnt;
                f=i;
            }
        }
        for(int i=1;i<=m;i++)
        {
            s[(f-1)*m+i]='*';
        }
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(s[(i-1)*m+j]=='.')
                cnt++;
            }
            if(cnt<ans2)
            {
                ans2=cnt;
            }
        }
        printf("%d\n",ans1+ans2);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn];
int n,m;
int f(int x,int y)
{
    int ans=0;
    if(s[(x-1)*m+y]=='.')
        ans++;
    for(int i=1;i<x;i++)
    {
        if(s[(i-1)*m+y]=='.')
        ans++;
    }
    for(int i=x+1;i<=n;i++)
    {
        if(s[(i-1)*m+y]=='.')
        ans++;
    }
    for(int i=1;i<y;i++)
    {
        if(s[(x-1)*m+i]=='.')
        ans++;
    }
    for(int i=y+1;i<=m;i++)
    {
        if(s[(x-1)*m+i]=='.')
        ans++;
    }
    return ans;
}
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int tot=0;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[++tot]=getchar();
            }
        }
        int ans=0x3f3f3f3f;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                ans=min(ans,f(i,j));
                if(ans==0)
                {
                    i=n;break;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
char s[maxn];
int n,m;
struct test
{
    int len,id;
}r[maxn],l[maxn];
bool cmp(test a,test b)
{
    return a.len>b.len;
}
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int tot=1;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            getchar();
            for(int j=0;j<m;j++)
            {
                s[tot++]=getchar();
            }
        }
        int rtot=0,ltot=0;
        //行
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=m;j++)
            {
                if(s[(i-1)*m+j]=='*')
                cnt++;
            }
            r[rtot].len=cnt;
            r[rtot].id=i;
            rtot++;
        }
        //列
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(s[(i-1)*m+j]=='*')
                cnt++;
            }
            l[ltot].len=cnt;
            l[ltot].id=j;
            ltot++;
        }
        sort(r,r+rtot,cmp);
        sort(l,l+ltot,cmp);
        int rlen=r[0].len;
        int llen=l[0].len;
        int ans=0x3f3f3f3f;
        for(int i=0;r[i].len==rlen;i++)
        {
            for(int j=0;l[j].len==llen;j++)
            {
                int tt=m-r[i].len+n-l[j].len;
                if(s[(r[i].id-1)*m+l[j].id]=='.')
                tt--;
                ans=min(ans,tt);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   long long nr = 0, nc = 0;
   int row = 0, col = 0;
   for(int i = 0; i < n; ++i){
      long long r = 0;
      for(int j = 0; j < m; ++j){
         if(s[i][j] == '*') ++r;
      }
      if(r > nr){
         nr = r;
         row = i;
      }
   }
   long long ans = 1e9;
   for(int i = 0; i < m; ++i){
      long long c = 0;
      for(int j = 0; j < n; ++j){
         if(s[j][i] == '*') ++c;
      }
      ans = min(ans, n - nr + m - c - (s[row][col] == '.' ? 1 : 0));
   }
   cout << ans << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   long long R[n], C[m];
   for(int i = 0; i < n; ++i){
      R[i] = 0;
      cin >> s[i];
   }
   long long r = 0, c = 0, ans = 1e9;
   int row = 0, col = 0;
   for(int i = 0; i < n; ++i){
      R[i] = count(s[i].begin(), s[i].end(), '*');
   }
   for(int j = 0; j < m; ++j){
      C[j] = 0;
      c = 0;
      for(int k = 0; k < n; ++k){
         if(s[k][j] == '*') ++c;
      }
      C[j] = c;
   }
   for(int i = 0; i < n; ++i){
      for(int j = 0; j < m; ++j){
         ans = min(ans, n - R[i] + m - C[j] - (s[i][j] == '.' ? 1 : 0));
      }
   }
   cout << ans << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   long long nr = 0, nc = 0;
   int row = 0, col = 0;
   for(int i = 0; i < n; ++i){
      long long r = 0;
      for(int j = 0; j < m; ++j){
         if(s[i][j] == '*') ++r;
      }
      if(r > nr){
         nr = r;
         row = i;
      }
   }
   for(int i = 0; i < m; ++i){
      long long c = 0;
      for(int j = 0; j < n; ++j){
         if(s[j][i] == '*') ++c;
      }
      if(c > nc){
         nc = c;
         col = i;
      }
   }
   cout << n - nr + m - nc - (s[row][col] == '.' ? 1 : 0) << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   int nr = 0, nc = 0, row, col;
   for(int i = 0; i < n; ++i){
      int r = 0;
      for(int j = 0; j < m; ++j){
         if(s[i][j] == '*') ++r;
      }
      if(r > nr){
         nr = r;
         row = i;
      }
   }
   for(int i = 0; i < m; ++i){
      int c = 0;
      for(int j = 0; j < n; ++j){
         if(s[j][i] == '*') ++c;
      }
      if(c > nc){
         nc = c;
         col = i;
      }
   }
   if(s[row][col] == '.')
      cout << n - nr + m - nc - 1 << '\n';
   else
      cout << n - nr + m - nc << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   long long r = 0, c = 0, ans = 1e9;
   int row = 0, col = 0;
   for(int i = 0; i < n; ++i){
      r = count(s[i].begin(), s[i].end(), '*');
      for(int j = 0; j < m; ++j){
         c = 0;
         for(int k = 0; k < n; ++k){
            if(s[k][j] == '*') ++c;
         }
         ans = min(ans, n - r + m - c - (s[i][j] == '.' ? 1 : 0));
      }
   }
   cout << ans << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   long long nr = 0;
   int row = 0, col = 0;
   for(int i = 0; i < n; ++i){
      long long r = 0;
      for(int j = 0; j < m; ++j){
         if(s[i][j] == '*') ++r;
      }
      if(r > nr){
         nr = r;
         row = i;
      }
   }
   long long ans = 1e9;
   for(int i = 0; i < m; ++i){
      long long c = 0;
      for(int j = 0; j < n; ++j){
         if(s[j][i] == '*') ++c;
      }
      ans = min(ans, n - nr + m - c - (s[row][i] == '.' ? 1 : 0));
   }
   cout << ans << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printv(vector<int> arr, int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
void print(int arr[], int n){for(int i = 0; i < n; ++i) printf("%d ", arr[i]);cout<<endl;}
bool isPrime(int n){bool flag = 1;for(int i = 2; i <= sqrt(n); ++i){if(n % i == 0){flag = 0;break;}}return (flag ? 1 : 0);}

void test_case(){
   int n, m;
   cin >> n >> m;
   string s[n];
   for(int i = 0; i < n; ++i){
      cin >> s[i];
   }
   long long nr = 0, nc = 0;
   int row, col;
   for(int i = 0; i < n; ++i){
      long long r = 0;
      for(int j = 0; j < m; ++j){
         if(s[i][j] == '*') ++r;
      }
      if(r > nr){
         nr = r;
         row = i;
      }
   }
   for(int i = 0; i < m; ++i){
      long long c = 0;
      for(int j = 0; j < n; ++j){
         if(s[j][i] == '*') ++c;
      }
      if(c > nc){
         nc = c;
         col = i;
      }
   }
   cout << n - nr + m - nc - (s[row][col] == '.' ? 1 : 0) << '\n';
}

int main(){
   int t = 1;
   scanf("%d", &t);
   while(t--){
      test_case();
   }
   return 0;
}


#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<functional>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair

const int N=1e7+10;
const long long INF=1e18;
const double eps=0.0000001;
const ll mod=1e9+7;
int n,m,x,y,t;

struct note
{
    int x,id;
}a[N],b[N];

bool cmp(note a,note b)
{
    return a.x<b.x;
}
char str[N];

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>t;
    while(t--)
    {
       memset(a,0,sizeof(a));
       memset(b,0,sizeof(b));
       scanf("%d%d",&n,&m);
       int vis[n][m]={0};
       for(int i=0;i<n;i++)
       {
           scanf("%s",str);
           for(int j=0;j<m;j++)
           {
               if(str[j]=='*')
                a[j].x++,a[j].id=j,b[i].x++,b[i].id=i;
               if(str[j]=='.')
                vis[i][j]=1;
           }
       }
       int flag=0,ans=N;
       for(int i=n-1;i>=0;i--)
       {
               for(int j=m-1;j>=0;j--)
               {
                       flag=0;
                       if(vis[i][j]==1)
                       {
                           flag=1;
                       }
                       if(flag==0)
                            ans=min(n+m-(a[j].x+b[i].x),ans);
                       else
                            ans=min(n+m-(a[j].x+b[i].x)-1,ans);

               }

       }
       printf("%d\n",ans);
    }
}

/*
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<functional>
#include<set>
#include<map>
#include<stack>
#include<iterator>
#include<queue>
#include<vector>
#include<string>
using namespace std;

const int maxn=1e5+7;
int st[maxn][20],st1[maxn][20],a[maxn],n;

void init(int n)
{
    for(int i=1;i<=n;i++)  st1[i][0]=st[i][0]=a[i];//��ʼ������i�㿪ʼ2^j���ȵļ�ֵ
    for(int j=1;j<20;j++)
        for(int i=1;i<=n;i++)
            if(i+(1<<(j-1))<n)
                st[i][j]=min(st[i][j-1],st[i+(1<<(j-1))][j-1]),
                st1[i][j]=max(st1[i][j-1],st1[i+(1<<(j-1))][j-1]); //��ֵ
}

int query(int l,int r)
{
    int len=log2(r-l+1);
    return max(st1[l][len],st1[r-(1<<len)+1][len])-min(st[l][len],st[r-(1<<len)+1][len]);
}

int main()
{
   ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\
   int n,s,len; cin>>n>>>s>>len;

    for(int i=1;i<=n;i++) cin>>a[i];
    init(n);
    int l,r;
    if(len>n||query(1,len)>s) return cout<<-1<<endl,0;
    memset(dp,inf,sizeof(dp)); dp[0]=0;

}
*/


#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<functional>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair

const int N=1e6+10;
const long long INF=1e18;
const double eps=0.0000001;
const ll mod=1e9+7;
int n,m,x,y,t;

int a[N],b[N];

char str[N];

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    scanf("%d",&t);
    while(t--)
    {
       memset(a,0,sizeof(a));
       memset(b,0,sizeof(b));
       scanf("%d%d",&n,&m);
       int vis[n][m];
       memset(vis,0,sizeof(vis));//��ʼ��
       for(int i=0;i<n;i++)
       {
           scanf("%s",str);
           for(int j=0;j<m;j++)
           {
               if(str[j]=='*')
                a[j]++,b[i]++;
               if(str[j]=='.')
                vis[i][j]=1;
           }
       }
       int flag=0,ans=N;
       for(int i=0;i<n;i++)
       {
               for(int j=0;j<=m;j++)
               {
                       flag=0;
                       if(vis[i][j]==1)
                       {
                           flag=1;
                       }
                       if(flag==0)
                            ans=min(n+m-(a[j]+b[i]),ans);
                       else
                            ans=min(n+m-(a[j]+b[i])-1,ans);
                       if(ans==0)
                          break;

               }
               if(ans==0)
               break;

       }

       printf("%d\n",ans);
    }
}

/*
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<functional>
#include<set>
#include<map>
#include<stack>
#include<iterator>
#include<queue>
#include<vector>
#include<string>
using namespace std;

const int maxn=1e5+7;
int st[maxn][20],st1[maxn][20],a[maxn],n;

void init(int n)
{
    for(int i=1;i<=n;i++)  st1[i][0]=st[i][0]=a[i];//��ʼ������i�㿪ʼ2^j���ȵļ�ֵ
    for(int j=1;j<20;j++)
        for(int i=1;i<=n;i++)
            if(i+(1<<(j-1))<n)
                st[i][j]=min(st[i][j-1],st[i+(1<<(j-1))][j-1]),
                st1[i][j]=max(st1[i][j-1],st1[i+(1<<(j-1))][j-1]); //��ֵ
}

int query(int l,int r)
{
    int len=log2(r-l+1);
    return max(st1[l][len],st1[r-(1<<len)+1][len])-min(st[l][len],st[r-(1<<len)+1][len]);
}

int main()
{
   ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\
   int n,s,len; cin>>n>>>s>>len;

    for(int i=1;i<=n;i++) cin>>a[i];
    init(n);
    int l,r;
    if(len>n||query(1,len)>s) return cout<<-1<<endl,0;
    memset(dp,inf,sizeof(dp)); dp[0]=0;

}
*/