#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if(ans2<a)
			{
				ans2=a;
				ans2-=(nb[ix][i]=='*');
			}

		}
		cout<<(n+m-1)-(ans1+ans2)<<endl;

	}
	return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if((ans2-(nb[ix][i]=='*'))<a)
			{
				ans2=a;
				ans2-=(nb[ix][i]=='*');
			}

		}
		cout<<(n+m-1)-(ans1+ans2)<<endl;

	}
	/*LA RESPUESTA ESTA MAL DEBIDO A QUE EN EL CASO
	    ..*..
	    ****.
	    **.**
	    ..*..
	    ..*..
	Fallaría al dar la respuesta
	*/
	return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if(ans2<a)
			{
				ans2=a;
				ans2+=(nb[ix][i]=='.');
			}

		}
		cout<<(n+m-1)-(ans1+ans2-1)<<endl;

	}
	return 0;
}


#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<n; i++)
#define PV(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PM(m) FORN(j,0,m.size()) {PV(m[j]);}
#define fi first
#define se second
#define p_b push_back
#define pp_b pop_back
#define mk_p make_pair
#define pr_setp(n)cout<<setprecision(2)<<n;
#define pr_setp1(n) cout<<setprecision(8)<<fixed<<n;
#define l_b lower_bound
#define u_b upper_bound
#define MAXP 1500000000000000000
typedef long long ll;
vector<ll>primes;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin>>q;
	while(q--)
	{
		int n,m;
		cin>>n>>m;
		int ans1(0),ans2(0);
		vector<vector<char>>nb(n,vector<char>(m));
		int ix(0);
		for(int i=0;i<n;++i)
		{
			int a(0);
			for(int j=0;j<m;++j)
			{
				cin>>nb[i][j];
				if(nb[i][j]=='*')++a;
			}
			if(ans1<=a)
			{
				ans1=a;
				ix=i;
			}
		//	ans1=max(ans1,a);
		}
		bool s(0);
		for(int i=0;i<m;++i)
		{
			int a(0);
			for(int j=0;j<n;++j)
			{
			//	cin>>nb[i][j];
				if(nb[j][i]=='*')++a;
			}
			if(ans2<=a)
			{
				ans2=a;
				ans2+=(nb[ix][i]=='.');
			}

		}
		int r=s?1:0;
		cout<<(n+m-1)-(ans1+ans2-1)<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000];
void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=0;
    }
}
int main()
{
    int n,m;

    int row_mx,colom_mx,row,col_ind;
    char ch;
    string st1,st_r;
    int tc;
    cin>>tc;
    for(int i=0;i<tc;i++)
    {
        st_r.clear();
        make_zero();
        row_mx=colom_mx=-1;
        col_ind=-1;
        cin>>n>>m;
        for(int j=0;j<n;j++)
        {
           st1.clear();
            row=0;
            for(int k=0;k<m;k++)
            {
                cin>>ch;
                st1.push_back(ch);
                if(ch=='*')
                {
                    row++;
                    colom[k]+=1;
                }
                if(colom[k]>colom_mx)
                {
                    colom_mx=colom[k];
                    col_ind=k;
                }
            }
            if(row>row_mx)
            {
                row_mx=row;
                st_r.clear();
                st_r=st1;
            }
            else if(row==row_mx && st1[col_ind]!='*')
            {
                row_mx=row;
                st_r.clear();
                st_r=st1;
            }
        }
        int res=(n-colom_mx)+(m-row_mx);
        if(st_r[col_ind]!='*')
        {
            res=res-1;
        }
      //  cout<<"result row is : "<<st_r<<endl;
        printf("%d\n",res);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000];
void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=0;
    }
}
int main()
{
    int n,m;

    int row_mx,colom_mx,row,col_ind;
    char ch;
    string st1,st_r,st[50000];
    int tc;
    cin>>tc;
    for(int i=0;i<tc;i++)
    {
        st_r.clear();
        make_zero();
        row_mx=colom_mx=-1;
        col_ind=-1;
        cin>>n>>m;
        for(int j=0;j<n;j++)
        {
            st[j].clear();
           st1.clear();
            row=0;
            for(int k=0;k<m;k++)
            {
                cin>>ch;
                st1.push_back(ch);
                st[j].push_back(ch);
                if(ch=='*')
                {
                    row++;
                    colom[k]+=1;
                }
                if(colom[k]>colom_mx)
                {
                    colom_mx=colom[k];
                    col_ind=k;
                }
                else if(colom[k]==colom_mx && st[j][k]!='*')
                {
                    colom_mx=colom[k];
                    col_ind=k;

                }
            }
            if(row>row_mx)
            {
                row_mx=row;
                st_r.clear();
                st_r=st1;
            }
            else if(row==row_mx && st1[col_ind]!='*')
            {
                row_mx=row;
                st_r.clear();
                st_r=st1;
            }
        }
        int res=(n-colom_mx)+(m-row_mx);
        if(st_r[col_ind]!='*')
        {
            res=res-1;
        }
      //  cout<<"result row is : "<<st_r<<endl;
        printf("%d\n",res);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000];
void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=0;
    }
}
int main()
{
    int n,m;
    int row_mx,colom_mx,row,col_ind;
    char ch;
    string st1,st_r;
    int tc;
    cin>>tc;
    for(int i=0;i<tc;i++)
    {
        st_r.clear();
        make_zero();
        row_mx=colom_mx=-1;
        col_ind=-1;
        cin>>n>>m;
        for(int j=0;j<n;j++)
        {
           st1.clear();
            row=0;
            for(int k=0;k<m;k++)
            {
                cin>>ch;
                st1.push_back(ch);
                if(ch=='*')
                {
                    row++;
                    colom[k]+=1;
                }
                if(colom[k]>colom_mx)
                {
                    colom_mx=colom[k];
                    col_ind=k;
                }
            }
            if(row>row_mx)
            {
                row_mx=row;
                st_r.clear();
                st_r=st1;
            }
        }
        int res=(n-colom_mx)+(m-row_mx);
        if(st_r[col_ind]!='*')
        {
            res=res-1;
        }
        printf("%d\n",res);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000];
void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=0;
    }
}
int main()
{
    int n,m;
    int row_mx,colom_mx,row,col_ind;
    char ch;
    string st1,st_r;
    int tc;
    cin>>tc;
    for(int i=0;i<tc;i++)
    {
        st_r.clear();
        make_zero();
        row_mx=colom_mx=0;
        col_ind=-1;
        cin>>n>>m;
        for(int j=0;j<n;j++)
        {
           st1.clear();
            row=0;
            for(int k=0;k<m;k++)
            {
                cin>>ch;
                st1.push_back(ch);
                if(ch=='*')
                {
                    row++;
                    colom[k]+=1;
                }
                if(colom[k]>colom_mx)
                {
                    colom_mx=colom[k];
                    col_ind=k;
                }
            }
            if(row>row_mx)
            {
                row_mx=row;
                st_r=st1;
            }
        }
        int res=(n-colom_mx)+(m-row_mx);
        if(st_r[col_ind]!='*')
        {
            res=res-1;
        }
        printf("%d\n",res);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000],rw[50000];

void make_zero(int a,int b)
{
    for(int i=0;i<a;i++)
    {
        rw[i]=0;
        //colom_mx_ar[i]=row_mx_ar[i]=0;
    }
    for(int i=0;i<b;i++)
    {
        colom[i]=0;
    }
}
int main()
{
    int n,m,mx;

    int row_mx[50000],colom_mx,row,col_ind;
    char ch;

    int tc;
    cin>>tc;
    for(int kase=0;kase<tc;kase++)
    {

        cin>>n>>m;
        char st[n][m];
        make_zero(n,m);
        for(int i=0;i<n;i++)
        {

            for(int j=0;j<m;j++)
            {
                cin>>ch;
                st[i][j]=ch;
                if(ch=='*')
                {
                    rw[i]=rw[i]+1;
                    colom[j]++;
                }
            }
        }
        int res=0,ans=INT_MAX;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                res=(m-colom[j])+(n-rw[i]);
                if(st[i][j]=='.')
                {
                    res=res-1;
                }
                ans=min(ans,res);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


/*_______________________________________
      Giving up try.
      __________________________________ */

#include <bits/stdc++.h>
using namespace std;
int colom[50000],rw[50000];

void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=rw[i]=0;
        //colom_mx_ar[i]=row_mx_ar[i]=0;
    }
}
int main()
{
    int n,m,mx;

    int row_mx[50000],colom_mx,row,col_ind;
    char ch;
    string st[50000];
    int tc;
    cin>>tc;
    for(int kase=0;kase<tc;kase++)
    {
        make_zero();
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {
            st[i].clear();
            for(int j=0;j<m;j++)
            {
                cin>>ch;
                st[i].push_back(ch);
                if(ch=='*')
                {
                    rw[i]=rw[i]+1;
                    colom[j]++;
                }
            }
        }
        int res=0,ans=INT_MAX;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                res=(m-colom[j])+(n-rw[i]);
                if(st[i][j]=='.')
                {
                    res=res-1;
                }
                ans=min(ans,res);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000],rw[50000];

void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=rw[i]=0;
        //colom_mx_ar[i]=row_mx_ar[i]=0;
    }
}
int main()
{
    int n,m,mx;

    int row_mx[50000],colom_mx,row,col_ind;
    char ch;
    char st[50005][50005];
    int tc;
    cin>>tc;
    for(int kase=0;kase<tc;kase++)
    {
        make_zero();
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {

            for(int j=0;j<m;j++)
            {
                cin>>ch;
                st[i][j]=ch;
                if(ch=='*')
                {
                    rw[i]=rw[i]+1;
                    colom[j]++;
                }
            }
        }
        int res=0,ans=INT_MAX;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                res=(m-colom[j])+(n-rw[i]);
                if(st[i][j]=='.')
                {
                    res=res-1;
                }
                ans=min(ans,res);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int colom[50000],rw[50000];

void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=rw[i]=0;
        //colom_mx_ar[i]=row_mx_ar[i]=0;
    }
}
int main()
{
    int n,m,mx;

    int row_mx[50000],colom_mx,row,col_ind;
    char ch;
    string st[50005];
    int tc;
    cin>>tc;
    for(int kase=0;kase<tc;kase++)
    {
        make_zero();
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {
            st[i].clear();
            for(int j=0;j<m;j++)
            {
                cin>>ch;
                st[i].push_back(ch);
                if(ch=='*')
                {
                    rw[i]=rw[i]+1;
                    colom[j]++;
                }
            }
        }
        int res=0,ans=INT_MAX;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                res=(m-colom[j])+(n-rw[i]);
                if(st[i][j]=='.')
                {
                    res=res-1;
                }
                ans=min(ans,res);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


/* __________________________________
   Eeeeeeeeeeeh
   _______________________________*/
#include <bits/stdc++.h>
using namespace std;
int colom[50000],rw[50000];

void make_zero()
{
    for(int i=0;i<50000;i++)
    {
        colom[i]=rw[i]=0;
        //colom_mx_ar[i]=row_mx_ar[i]=0;
    }
}
int main()
{
    int n,m,mx;

    int row_mx[50000],colom_mx,row,col_ind;
    char ch;

    int tc;
    cin>>tc;
    for(int kase=0;kase<tc;kase++)
    {
        make_zero();
        cin>>n>>m;
        char st[n][m];
        for(int i=0;i<n;i++)
        {

            for(int j=0;j<m;j++)
            {
                cin>>ch;
                st[i][j]=ch;
                if(ch=='*')
                {
                    rw[i]=rw[i]+1;
                    colom[j]++;
                }
            }
        }
        int res=0,ans=INT_MAX;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                res=(m-colom[j])+(n-rw[i]);
                if(st[i][j]=='.')
                {
                    res=res-1;
                }
                ans=min(ans,res);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=4000005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	LOOP : int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];
    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	++fck;
    		 	goto LOOP;

    		 }
    	}

    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];

    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	//cout << a[1][1];
    	int minn=mx;
    	rep(i,n)rep(j,m){
    		minn=min(minn,(n+m-y[i]-d[j]));
    		if(a[i][j]==0)minn=min(minn,n+m-1-y[i]-d[j]);
    		//cout << i<<":" <<y[i] << " "<<j<<":" << d[j]<<endl;
    	}
    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	LOOP : int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];
    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	++fck;
    		 	goto LOOP;

    		 }
    	}

    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];
    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	goto LOOP;

    		 }
    	}

    	LOOP : cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=4000005;

ll d[mx],y[mx];
int main(){
	#define int long long
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	LOOP : int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];
    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	++fck;
    		 	goto LOOP;

    		 }
    	}

    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];

    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    	}
    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	string s[n];

    	rep(i,n)rep(j,m){
    		cin >> s[i][j];
    		if(s[i][j]=='*'){
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(s[0][0]=='.');
    	rep(i,n)rep(j,m){
            if((n+m-y[i]-d[j]-(s[i][j]=='.'))<minn)minn=n+m-y[i]-d[j]-(s[i][j]=='.');
    	}
    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	LOOP : int n,m;
    	cin >> n >> m;

    	char ak;
    	int a[n][m];
    	rep(i,n)y[i]=0;
    	rep(j,m)d[j]=0;
    	rep(i,n)rep(j,m){
    		a[i][j]=0;
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	++fck;
    		 	goto LOOP;

    		 }
    	}

    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];

    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=mx;
    	rep(i,n)rep(j,m){
    		minn=min(minn,n+m-y[i]-d[j]-(a[i][j]==0));
    	}
    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	LOOP : int n,m;
    	cin >> n >> m;

    	int y[n]={0},d[m]={0};
    	char ak;
    	int a[n][m];
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	++fck;
    		 	goto LOOP;

    		 }
    	}

    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    rep(fck,t){
    	int n,m;
    	cin >> n >> m;
    	memset(d,0,sizeof(d));
    	memset(y,0,sizeof(y));
    	char ak;
    	int a[n][m];

    	memset(a,0,sizeof(a));
    	rep(i,n)rep(j,m){
    		cin >> ak;
    		if(ak=='*'){
    			a[i][j]=1;
    			++d[j];++y[i];
    		}
    	}
    	int minn=n+m-y[0]-d[0]-(a[0][0]==0);
    	rep(i,n)rep(j,m){
    		 if((n+m-y[i]-d[j]-(a[i][j]==0))<minn)minn=n+m-y[i]-d[j]-(a[i][j]==0);
    		 if(minn==0){
    		 	cout << minn << endl;
    		 	return 0;
    		 }
    	}
    	cout << minn << endl;

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=400005;
int d[mx],y[mx];
string s[50005];
void solve(){
	int n,m;
	cin >> n >> m;
	vector <int> row(n+1,0),col(m+1,0);
	for(int i=1;i<=n;++i)cin >> s[i];
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			row[i]+=(s[i][j-1]=='*');
			col[j]+=(s[i][j-1]=='*');
		}
	}
	int ans=INF;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			int zar=(s[i][j-1]=='*');
			ans=min(ans,n+m-1-(row[i]+col[j]-zar));
		}
	}
	cout << ans << endl;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t;cin >> t;
    while(t--){
    	solve();
    }
    return 0;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "B"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

signed main() {
    freekick();
    freegoal();
    int t;
    cin >> t;
    char a[50001][40001];
    while (t--) {
        int n, m;
        cin >> n >> m;
        int maxRow = 0, maxCol = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            int curRow = 0;
            for (int j = 0; j < m; j++) {
                if (a[i][j]=='*') {
                    curRow++;
                }
            }
            maxRow = max(maxRow, curRow);
        }
        for (int j = 0; j < m; j++) {
            int curCol = 0;
            for (int i = 0; i < n; i++) {
                if (a[i][j] == '*') {
                    curCol++;
                }
            }
            maxCol = max(maxCol, curCol);
        }
        cout << (n - maxCol) + (m - maxRow) << endl;
    }
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "C"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

signed main() {
    freekick();
    freegoal();
    ll t = 1;
    cin >> t;
    while (t--) {
        ll n, m;
        cin >> n >> m;
        string s[n + 5];
        for (int i = 0; i < n; i++)
            cin >> s[i];
            ll maxi = -1, i_index, ans = 0, j_index;
            for (int i = 0; i < n; i++) {
                ll p = 0;
                for (int j = 0; j < m; j++) {
                    if (s[i][j] == '*')
                    p++;
                }
                if (p > maxi) {
                    maxi = p;
                    i_index = i;
                }
            }
            ans += m - maxi;
            for (int i = 0; i < m; i++) {
                s[i_index][i] = '*';
            }
            maxi = -1;
       for (int j = 0; j < m; j++) {
            ll p = 0;
            for (int i = 0; i < n; i++) {
                if (s[i][j] == '*')
                    p++;
            }
            if (p > maxi) {
               maxi = p;
               j_index = j;
           }
        }
        ans += n - maxi;
        cout << ans << endl;
    }
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "C"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

void p() {
    ll n, m, mxc = 0, mxr = 0;
    cin >> n >> m;
    vector<ll> r, c;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '*') cnt++;
        }
        if (mxr < cnt) {
            r.clear();
            r.pb(i);
            mxr = cnt;
        }
        else if (mxr == cnt) {
            r.push_back(i);
        }
    }
    for (int i = 0; i < m; i++) {
        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            if (s[j][i] == '*')
                cnt++;
        }
        if (mxc < cnt) {
            c.clear();
            c.pb(i);
            mxc = cnt;
        }
        else if (mxc == cnt) {
            c.pb(i);
        }
    }
    ll flag = 0;
    for (int i = 0; i < r.size(); i++) {
        for (int j = 0; j < c.size(); j++) {
            if (s[r[i]][c[j]] == '.') {
                flag = 1;
            }
        }
    }
    cout << m + n - mxc - mxr - flag << endl;
}

signed main() {
    freekick();
    freegoal();
    ll t;
    cin >> t;
    for (int i = 0; i < t; i++)
        p();
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "B"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int t, n, m;
char a[50001][40001];
signed main() {
    freekick();
    freegoal();
    cin >> t;
    while (t--) {
        cin >> n >> m;
        int cnt = 0, res = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            int adj = 0;
            for (int j = 0; j < m; j++) {
                if (a[i][j] == '*') {
                    adj++;
                }
            }
            cnt = max(cnt, adj);
        }
        for (int j = 0; j < m; j++) {
            int num = 0;
            for (int i = 0; i < n; i++) {
                if (a[i][j] == '*') {
                    num++;
                }
            }
            res = max(res, num);
        }
        cout << (n - res) + (m - cnt) << endl;
    }
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "B"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

void p() {
    ll n, m, mxc = 0, mxr = 0;
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '*') cnt++;
        }
        mxr = max(mxr, cnt);
    }
    for (int i = 0; i < m; i++) {
        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            if (s[j][i] == '*') cnt++;
        }
        mxc = max(mxc, cnt);
    }
    cout << m + n - mxc - mxr << endl;
}
signed main() {
    freekick();
    freegoal();
    ll n, x, t;
    cin >> t;
    for (int i = 0; i < t; i++)
        p();
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "C"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

void p() {
    ll n, m, mxc = 0, mxr = 0;
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '*') cnt++;
        }
        mxr = max(mxr, cnt);
    }
    for (int i = 0; i < m; i++) {
        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            if (s[j][i] == '*') cnt++;
        }
        mxc = max(mxc, cnt);
    }
    cout << m + n - mxc - mxr << endl;
}

signed main() {
    freekick();
    freegoal();
    ll n, x, t;
    cin >> t;
    for (int i = 0; i < t; i++)
        p();
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "B"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

char a[50001][40001];
signed main() {
    freekick();
    freegoal();
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        int maxRow = 0, maxCol = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            int curRow = 0;
            for (int j = 0; j < m; j++) {
                if (a[i][j]=='*') {
                    curRow++;
                }
            }
            maxRow = max(maxRow, curRow);
        }
        for (int j = 0; j < m; j++) {
            int curCol = 0;
            for (int i = 0; i < n; i++) {
                if (a[i][j] == '*') {
                    curCol++;
                }
            }
            maxCol = max(maxCol, curCol);
        }
        cout << (n - maxCol) + (m - maxRow) << endl;
    }
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "C"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

signed main() {
    freekick();
    freegoal();
    int q;
    cin >> q;
    while (q--) {
        int n, m, k = 0;
        cin >> n >> m;
        vector<vector<char> > a(n, vector<char> (m));
        for (int i = 0; i < n; i++) {
            int adj = 0;
            for (int j = 0; j < m; j++) {
                cin >> a[i][j];
                if (a[i][j] == '*')
                    adj++;
            }
            k = max(k, adj);
        }
        for (int i = 0; i < n; i++) {
            int adj = 0;
            for (int j = 0; j < m; j++)
                if (a[i][j] == '*')
                    adj++;
            if (adj == k)
                for (int j = 0; j < m; j++)
                    a[i][j] = '*';
        }
        int ans = m - k;
        k = 0;
        for (int i = 0; i < m; i++) {
            int adj = 0;
            for (int j = 0; j < n; j++)
                if (a[j][i] == '*')
                    adj++;
                k = max(k, adj);
        }
        ans += n - k;
        cout << ans << "\n";
    }
    return false;
}


/// Quality Over Quantity

#include <bits/stdc++.h>

#define FILE_NAME "B"

using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define SZ(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define what_is(x) cerr << #x << " is " << x << endl;

void freekick() {
#ifndef ONLINE_JUDGE
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
}

const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};

void freegoal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

signed main() {
    freekick();
    freegoal();
    ll n, m, mxc = 0, mxr = 0;
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '*') cnt++;
        }
        mxr = max(mxr, cnt);
    }
    for (int i = 0; i < m; i++) {
        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            if (s[j][i] == '*') cnt++;
        }
        mxc = max(mxc, cnt);
    }
    cout << m + n - mxc - mxr << endl;
    return false;
}


    #include <bits/stdc++.h>
    using namespace std;

    int main() {
        int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt, finalans;
        long long ans;
        char ch;
        cin>>q;
        while (q--)
        {
            cin>>n>>m;
            ans = 0;
            vector<vector< char> > grid;
            maxfilledrow = 0;
            maxfilledcol = 0;
            vector<int> maxfilledrows;
            vector<int> maxfilledcols;
            for (int i=0; i<n; i++)
            {
                vector<char> temp;
                for (int j=0; j<m; j++)
                {
                    cin>>ch;
                    temp.push_back(ch);
                }
                grid.push_back(temp);
            }
            maxblacks = 0;
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt > maxblacks)
                {
                    maxblacks = rowcnt;
                    maxfilledrow = i;
                }
            }
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt == maxblacks)
                {
                    maxfilledrows.push_back(i);
                }
            }
            maxblacks = 0;
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt > maxblacks)
                {
                    maxblacks = colcnt;
                    maxfilledcol = i;
                }
            }
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt == maxblacks)
                {
                    maxfilledcols.push_back(i);
                }
            }
            finalans = INT_MAX;
            for (int k=0; k<maxfilledrows.size(); k++)
            {
                ans = 0;
                maxfilledrow = maxfilledrows[k];
                for (int i=0; i<m; i++)
                {
                    if (grid[maxfilledrow][i] == '.')
                    {
                        ans += 1;
                    }
                }
                int t = ans;
                for (int l=0; l<maxfilledcols.size(); l++)
                {
                    maxfilledcol = maxfilledcols[l];
                    for (int j=0; j<n; j++)
                    {
                        if (grid[j][maxfilledcol] == '.' && j != maxfilledrow)
                        {
                            ans += 1;
                        }
                    }
                    if (ans < finalans)
                    {
                        finalans = ans;
                    }
                    ans = t;
                }
            }
            // count whites in maxfilledcol
            cout<<finalans<<endl;
        }
        return 0;
    }


#include <bits/stdc++.h>
using namespace std;

int main() {
    int q, n, m, cnt;
    long long ans;
    char e;
    cin>>q;
    while (q--)
    {
        cin>>n>>m;
        vector<vector<char> > grid;
        vector<vector<int> > whitecnts;
        for (int i=0; i<n; i++)
        {
            vector<char> temp;
            vector<int> temp1(m);
            for (int j=0; j<m; j++)
            {
                cin>>e;
                temp.push_back(e);
            }
            grid.push_back(temp);
            whitecnts.push_back(temp1);
        }
        // row count of whites for each cell
        for (int i=0; i<n; i++)
        {
            cnt = 0;
            for (int j=0; j<m; j++)
            {
                if (grid[i][j] == '.')
                cnt += 1;
            }
            for (int j=0; j<m; j++)
            {
                whitecnts[i][j] = cnt;
            }
        }
        // col count of whites for each cell
        for (int i=0; i<m; i++)
        {
            cnt = 0;
            for (int j=0; j<n; j++)
            {
                if (grid[j][i] == '.')
                cnt += 1;
            }
            for (int j=0; j<n; j++)
            {
                whitecnts[j][i] += cnt;
            }
        }
        ans = INT_MAX;
        // subtract whites
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<m; j++)
            {
                if (grid[i][j] == '.')
                {
                    whitecnts[i][j] -= 1;
                }
                if (whitecnts[i][j] < ans)
                {
                    ans = whitecnts[i][j];
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
	long long ans;
	char ch;
	cin>>q;
	while (q--)
	{
		cin>>n>>m;
		vector<vector< char> > grid;
		maxfilledrow = 0;
		maxfilledcol = 0;
		for (int i=0; i<n; i++)
		{
			vector<char> temp;
			for (int j=0; j<m; j++)
			{
				cin>>ch;
				temp.push_back(ch);
			}
			grid.push_back(temp);
		}
		maxblacks = 0;
		for (int i=0; i<n; i++)
		{
			rowcnt = 0;
			for (int j=0; j<m; j++)
			{
				if (grid[i][j] == '*')
				rowcnt += 1;
			}
			if (rowcnt > maxblacks)
			{
				maxblacks = rowcnt;
				maxfilledrow = i;
			}
		}
		maxblacks = 0;
		for (int i=0; i<m; i++)
		{
			colcnt = 0;
			for (int j=0; j<n; j++)
			{
				if (grid[j][i] == '*')
				colcnt += 1;
			}
			if (colcnt >= maxblacks)
			{
				maxblacks = colcnt;
				maxfilledcol = i;
			}
		}
		ans = 0;
		// count whites in maxfilledrow
		// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
		for (int i=0; i<m; i++)
		{
			if (grid[maxfilledrow][i] == '.')
			{
				ans += 1;
				grid[maxfilledrow][i] = '*';
			}
		}
		// count whites in maxfilledcol
		for (int i=0; i<n; i++)
		{
			if (grid[i][maxfilledcol] == '.')
			{
				ans += 1;
				grid[i][maxfilledcol] = '*';
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


    #include <bits/stdc++.h>
    using namespace std;

    int main() {
        int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt, finalans;
        long long ans;
        char ch;
        cin>>q;
        while (q--)
        {
            cin>>n>>m;
            ans = 0;
            vector<vector< char> > grid;
            maxfilledrow = 0;
            maxfilledcol = 0;
            vector<int> maxfilledrows;
            vector<int> maxfilledcols;
            for (int i=0; i<n; i++)
            {
                vector<char> temp;
                for (int j=0; j<m; j++)
                {
                    cin>>ch;
                    temp.push_back(ch);
                }
                grid.push_back(temp);
            }
            maxblacks = 0;
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt > maxblacks)
                {
                    maxblacks = rowcnt;
                    maxfilledrow = i;
                }
            }
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt == maxblacks)
                {
                    maxfilledrows.push_back(i);
                }
            }
            maxblacks = 0;
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt > maxblacks)
                {
                    maxblacks = colcnt;
                    maxfilledcol = i;
                }
            }
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt == maxblacks)
                {
                    maxfilledcols.push_back(i);
                }
            }
            finalans = INT_MAX;
            for (int k=0; k<maxfilledrows.size(); k++)
            {
                ans = 0;
                maxfilledrow = maxfilledrows[i];
                for (int i=0; i<m; i++)
                {
                    if (grid[maxfilledrow][i] == '.')
                    {
                        ans += 1;
                    }
                }
                int t = ans;
                for (int l=0; l<maxfilledcols.size(); l++)
                {
                    maxfilledcol = maxfilledcols[l];
                    for (int l=0; j<n; j++)
                    {
                        if (grid[j][maxfilledcol] == '.' && j != maxfilledrow)
                        {
                            ans += 1;
                        }
                    }
                    if (ans < finalans)
                    {
                        finalans = ans;
                    }
                    ans = t;
                }
            }
            // count whites in maxfilledcol
            cout<<finalans<<endl;
        }
        return 0;
    }


#include <bits/stdc++.h>
using namespace std;

int main() {
	int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
	long long ans;
	char ch;
	cin>>q;
	while (q--)
	{
		cin>>n>>m;
		ans = 0;
		vector<vector< char> > grid;
		maxfilledrow = 0;
		maxfilledcol = 0;
		for (int i=0; i<n; i++)
		{
			vector<char> temp;
			for (int j=0; j<m; j++)
			{
				cin>>ch;
				temp.push_back(ch);
			}
			grid.push_back(temp);
		}
		maxblacks = 0;
		for (int i=0; i<n; i++)
		{
			rowcnt = 0;
			for (int j=0; j<m; j++)
			{
				if (grid[i][j] == '*')
				rowcnt += 1;
			}
			if (rowcnt > maxblacks)
			{
				maxblacks = rowcnt;
				maxfilledrow = i;
			}
		}
		// count whites in maxfilledrow
		// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
		for (int i=0; i<m; i++)
		{
			if (grid[maxfilledrow][i] == '.')
			{
				ans += 1;
				grid[maxfilledrow][i] = '*';
			}
		}
		maxblacks = 0;
		for (int i=0; i<m; i++)
		{
			colcnt = 0;
			for (int j=0; j<n; j++)
			{
				if (grid[j][i] == '*')
				colcnt += 1;
			}
			if (colcnt > maxblacks)
			{
				maxblacks = colcnt;
				maxfilledcol = i;
			}
		}
		// count whites in maxfilledcol
		for (int i=0; i<n; i++)
		{
			if (grid[i][maxfilledcol] == '.')
			{
				ans += 1;
				grid[i][maxfilledcol] = '*';
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
    long long ans;
    char ch;
    cin>>q;
    while (q--)
    {
        cin>>n>>m;
        ans = 0;
        vector<vector< char> > grid;
        maxfilledrow = 0;
        maxfilledcol = 0;
        vector<int> maxfilledrows;
        for (int i=0; i<n; i++)
        {
            vector<char> temp;
            for (int j=0; j<m; j++)
            {
                cin>>ch;
                temp.push_back(ch);
            }
            grid.push_back(temp);
        }
        maxblacks = 0;
        for (int i=0; i<n; i++)
        {
            rowcnt = 0;
            for (int j=0; j<m; j++)
            {
                if (grid[i][j] == '*')
                rowcnt += 1;
            }
            if (rowcnt > maxblacks)
            {
                maxblacks = rowcnt;
                maxfilledrow = i;
            }
        }
        for (int i=0; i<n; i++)
        {
            rowcnt = 0;
            for (int j=0; j<m; j++)
            {
                if (grid[i][j] == '*')
                rowcnt += 1;
            }
            if (rowcnt == maxblacks)
            {
                maxfilledrows.push_back(i);
            }
        }
        // count whites in maxfilledrow
        ans = m - maxblacks;
        if (m == 1)
        {
            maxblacks = 0;
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt > maxblacks)
                {
                    maxblacks = colcnt;
                    maxfilledcol = i;
                }
            }
            // count whites in maxfilledcol
            for (int i=0; i<n; i++)
            {
                if (grid[i][maxfilledcol] == '.' && i != maxfilledrow)
                {
                    ans += 1;
                    grid[i][maxfilledcol] = '*';
                }
            }
            cout<<ans<<endl;
            continue;
        }
        for (int k=0; k<maxfilledrows.size(); k++)
        {
            maxfilledrow = maxfilledrows[k];
            for (int i=0; i<m; i++)
            {
                if (grid[maxfilledrow][i] == '.')
                {
                    grid[maxfilledrow][i] = '*';
                }
            }
        }
        maxblacks = 0;
        for (int i=0; i<m; i++)
        {
            colcnt = 0;
            for (int j=0; j<n; j++)
            {
                if (grid[j][i] == '*')
                colcnt += 1;
            }
            if (colcnt > maxblacks)
            {
                maxblacks = colcnt;
                maxfilledcol = i;
            }
        }
        // count whites in maxfilledcol
        for (int i=0; i<n; i++)
        {
            if (grid[i][maxfilledcol] == '.')
            {
                ans += 1;
                grid[i][maxfilledcol] = '*';
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;

    int main() {
        int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
        long long ans;
        char ch;
        cin>>q;
        while (q--)
        {
            cin>>n>>m;
            ans = 0;
            vector<vector< char> > grid;
            maxfilledrow = 0;
            maxfilledcol = 0;
            vector<int> maxfilledrows;
            for (int i=0; i<n; i++)
            {
                vector<char> temp;
                for (int j=0; j<m; j++)
                {
                    cin>>ch;
                    temp.push_back(ch);
                }
                grid.push_back(temp);
            }
            maxblacks = 0;
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt > maxblacks)
                {
                    maxblacks = rowcnt;
                    maxfilledrow = i;
                }
            }
            for (int i=0; i<n; i++)
            {
                rowcnt = 0;
                for (int j=0; j<m; j++)
                {
                    if (grid[i][j] == '*')
                    rowcnt += 1;
                }
                if (rowcnt == maxblacks)
                {
                    maxfilledrows.push_back(i);
                }
            }
            // count whites in maxfilledrow
            ans = m - maxblacks;
            for (int k=0; k<maxfilledrows.size(); k++)
            {
                maxfilledrow = maxfilledrows[k];
                for (int i=0; i<m; i++)
                {
                    if (grid[maxfilledrow][i] == '.')
                    {
                        grid[maxfilledrow][i] = '*';
                    }
                }
            }
            maxblacks = 0;
            for (int i=0; i<m; i++)
            {
                colcnt = 0;
                for (int j=0; j<n; j++)
                {
                    if (grid[j][i] == '*')
                    colcnt += 1;
                }
                if (colcnt > maxblacks)
                {
                    maxblacks = colcnt;
                    maxfilledcol = i;
                }
            }
            // count whites in maxfilledcol
            for (int i=0; i<n; i++)
            {
                if (grid[i][maxfilledcol] == '.')
                {
                    ans += 1;
                    grid[i][maxfilledcol] = '*';
                }
            }
            cout<<ans<<endl;
        }
        return 0;
    }


#include <bits/stdc++.h>
using namespace std;

int main() {
	int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
	long long ans;
	char ch;
	cin>>q;
	while (q--)
	{
		cin>>n>>m;
		ans = 0;
		vector<vector< char> > grid;
		maxfilledrow = 0;
		maxfilledcol = 0;
		for (int i=0; i<n; i++)
		{
			vector<char> temp;
			for (int j=0; j<m; j++)
			{
				cin>>ch;
				temp.push_back(ch);
			}
			grid.push_back(temp);
		}
		maxblacks = 0;
		for (int i=0; i<n; i++)
		{
			rowcnt = 0;
			for (int j=0; j<m; j++)
			{
				if (grid[i][j] == '*')
				rowcnt += 1;
			}
			if (rowcnt >= maxblacks)
			{
				maxblacks = rowcnt;
				maxfilledrow = i;
			}
		}
		maxblacks = 0;
		for (int i=0; i<m; i++)
		{
			colcnt = 0;
			for (int j=0; j<n; j++)
			{
				if (grid[j][i] == '*')
				colcnt += 1;
			}
			if (colcnt >= maxblacks)
			{
				maxblacks = colcnt;
				maxfilledcol = i;
			}
		}
		ans = 0;
		if (maxfilledrow > maxfilledcol)
		{
			// count whites in maxfilledrow
			// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
			for (int i=0; i<m; i++)
			{
				if (grid[maxfilledrow][i] == '.')
				{
					ans += 1;
					grid[maxfilledrow][i] = '*';
				}
			}
			maxblacks = 0;
			for (int i=0; i<m; i++)
			{
				colcnt = 0;
				for (int j=0; j<n; j++)
				{
					if (grid[j][i] == '*')
					colcnt += 1;
				}
				if (colcnt >= maxblacks)
				{
					maxblacks = colcnt;
					maxfilledcol = i;
				}
			}
			// count whites in maxfilledcol
			for (int i=0; i<n; i++)
			{
				if (grid[i][maxfilledcol] == '.')
				{
					ans += 1;
					grid[i][maxfilledcol] = '*';
				}
			}
			cout<<ans<<endl;
		}
		else
		{
			// count whites in maxfilledcol
			for (int i=0; i<n; i++)
			{
				if (grid[i][maxfilledcol] == '.')
				{
					ans += 1;
					grid[i][maxfilledcol] = '*';
				}
			}
			maxblacks = 0;
			for (int i=0; i<n; i++)
			{
				rowcnt = 0;
				for (int j=0; j<m; j++)
				{
					if (grid[i][j] == '*')
					rowcnt += 1;
				}
				if (rowcnt >= maxblacks)
				{
					maxblacks = rowcnt;
					maxfilledrow = i;
				}
			}
			// count whites in maxfilledrow
			// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
			for (int i=0; i<m; i++)
			{
				if (grid[maxfilledrow][i] == '.')
				{
					ans += 1;
					grid[maxfilledrow][i] = '*';
				}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
	long long ans;
	char ch;
	cin>>q;
	while (q--)
	{
		cin>>n>>m;
		ans = 0;
		vector<vector< char> > grid;
		maxfilledrow = 0;
		maxfilledcol = 0;
		for (int i=0; i<n; i++)
		{
			vector<char> temp;
			for (int j=0; j<m; j++)
			{
				cin>>ch;
				temp.push_back(ch);
			}
			grid.push_back(temp);
		}
		maxblacks = 0;
		for (int i=0; i<n; i++)
		{
			rowcnt = 0;
			for (int j=0; j<m; j++)
			{
				if (grid[i][j] == '*')
				rowcnt += 1;
			}
			if (rowcnt >= maxblacks)
			{
				maxblacks = rowcnt;
				maxfilledrow = i;
			}
		}
		// count whites in maxfilledrow
		// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
		for (int i=0; i<m; i++)
		{
			if (grid[maxfilledrow][i] == '.')
			{
				ans += 1;
				grid[maxfilledrow][i] = '*';
			}
		}
		maxblacks = 0;
		for (int i=0; i<m; i++)
		{
			colcnt = 0;
			for (int j=0; j<n; j++)
			{
				if (grid[j][i] == '*')
				colcnt += 1;
			}
			if (colcnt >= maxblacks)
			{
				maxblacks = colcnt;
				maxfilledcol = i;
			}
		}
		// count whites in maxfilledcol
		for (int i=0; i<n; i++)
		{
			if (grid[i][maxfilledcol] == '.')
			{
				ans += 1;
				grid[i][maxfilledcol] = '*';
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int q, n, m, maxfilledrow, maxfilledcol, maxblacks, rowcnt, colcnt;
	long long ans;
	char ch;
	cin>>q;
	while (q--)
	{
		cin>>n>>m;
		vector<vector< char> > grid;
		maxfilledrow = 0;
		maxfilledcol = 0;
		for (int i=0; i<n; i++)
		{
			vector<char> temp;
			for (int j=0; j<m; j++)
			{
				cin>>ch;
				temp.push_back(ch);
			}
			grid.push_back(temp);
		}
		maxblacks = 0;
		for (int i=0; i<n; i++)
		{
			rowcnt = 0;
			for (int j=0; j<m; j++)
			{
				if (grid[i][j] == '*')
				rowcnt += 1;
			}
			if (rowcnt > maxblacks)
			{
				maxblacks = rowcnt;
				maxfilledrow = i;
			}
		}
		maxblacks = 0;
		for (int i=0; i<m; i++)
		{
			colcnt = 0;
			for (int j=0; j<n; j++)
			{
				if (grid[j][i] == '*')
				colcnt += 1;
			}
			if (colcnt > maxblacks)
			{
				maxblacks = colcnt;
				maxfilledcol = i;
			}
		}
		ans = 0;
		// count whites in maxfilledrow
		// cout<<maxfilledrow<<" "<<maxfilledcol<<endl;
		for (int i=0; i<m; i++)
		{
			if (grid[maxfilledrow][i] == '.')
			{
				ans += 1;
				grid[maxfilledrow][i] = '*';
			}
		}
		// count whites in maxfilledcol
		for (int i=0; i<n; i++)
		{
			if (grid[i][maxfilledcol] == '.')
			{
				ans += 1;
				grid[i][maxfilledcol] = '*';
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 1e9;
  	cin >> n >> m;
  	ll ro[n], co[m];
  	char c[n][m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '.')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  		// cout << a << " ";
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '.')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  		// cout << a << " ";
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(c[i][j] == '.' && row + col - 1 < sm)
         	{
         		sm = row + col - 1;
         	}
         	if(c[i][j] == '*' && row + col < sm)
         	{
         		sm = row + col;
         	}
    	}
    }
    cout << sm << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 0;
  	cin >> n >> m;
  	char c[n][m],ro[n], co[m];
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '*')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '*')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(row + col > sm)
         	{
         		sm = row + col;
         	}
    	}
    }
    cout << n + m - sm << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 0;
  	cin >> n >> m;
  	char c[n][m],ro[n], co[m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '*')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  		// cout << a << " ";
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '*')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  		// cout << a << " ";
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(c[i][j] == '*' && row + col > sm)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
         	if(c[i][j] == '.' && row + col > sm - 1)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
    	}
    }
    if(p == '*')
    cout << n + m - sm << endl;
    else
    cout << m + n - sm - 1 << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 1e9;
  	cin >> n >> m;
  	ll ro[n] = {0}, co[m] = {0};
  	char c[n][m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '.')
  			{
  				ro[i]++;
  				co[j]++;
  			}
  		}
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	sm = min(sm, row + col - (c[i][j] == '.'));
    	}
    }
    cout << sm << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 0;
  	cin >> n >> m;
  	char c[n][m],ro[n], co[m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '*')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '*')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(row + col > sm)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
    	}
    }
    if(p == '*')
    cout << n + m - sm << endl;
    else
    cout << m + n - sm - 1 << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 1e9;
  	cin >> n >> m;
  	char c[n][m],ro[n], co[m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '.')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  		// cout << a << " ";
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '.')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  		// cout << a << " ";
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(c[i][j] == '.' && row + col - 1 < sm)
         	{
         		sm = row + col - 1;
         	}
         	if(c[i][j] == '*' && row + col < sm)
         	{
         		sm = row + col;
         	}
    	}
    }
    cout << sm << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 0;
  	cin >> n >> m;
  	char c[n][m],ro[n], co[m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '*')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  		cout << a << " ";
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '*')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  		cout << a << " ";
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(c[i][j] == '*' && row + col > sm)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
         	if(c[i][j] == '.' && row + col > sm - 1)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
    	}
    }
    if(p == '*')
    cout << n + m - sm << endl;
    else
    cout << m + n - sm - 1 << endl;
  }

  return 0;
}


// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

 int main()
{
   fast();

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
  #endif
  ll q;
  cin >> q;
  while(q--)
  {
  	ll n, m, row = 0, col = 0, sm = 0;
  	cin >> n >> m;
  	ll ro[m], co[m];
  	char c[n][m], p;
  	f(i,0,n)
  	{
  		ll a = 0;
  		f(j,0,m)
  		{
  			cin >> c[i][j];
  			if(c[i][j] == '*')
  			{
  				a++;
  			}
  		}
  		ro[i] = a;
  		// cout << a << " ";
  	}
  	f(i,0,m)
  	{
  		ll a = 0;
  		f(j,0,n)
  		{
  			if(c[j][i] == '*')
  			{
                a++;
  			}
  		}
  		co[i] = a;
  		// cout << a << " ";
  	}
    f(i,0,n)
    {
    	f(j,0,m)
    	{
         	row = ro[i];
         	col = co[j];
         	if(c[i][j] == '*' && row + col > sm)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
         	if(c[i][j] == '.' && row + col > sm - 1)
         	{
         		sm = row + col;
         		p = c[i][j];
         	}
    	}
    }
    if(p == '*')
    cout << n + m - sm << endl;
    else
    cout << m + n - sm - 1 << endl;
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin>>t;
    while(t--){
        int row, col; cin >> row >> col;
        char arr[row][col];
        int r[row]; int c[col];
        memset(r,0,sizeof(r));
        memset(c, 0, sizeof(c));
        f(i,0,row){
            f(j,0,col){
                cin>>arr[i][j];
            }
        }
        f(i,0,row){
            int cnt = 0;
            f(j,0,col){
                if(arr[i][j] == '.') cnt++;
            }
            r[i] = cnt;
        }
        f(j,0,col){
            int cnt = 0;
            f(i,0,row){
                if(arr[i][j] == '.') cnt++;
            }
            c[j] = cnt;
        }
        int ans = INT_MAX;
        f(i,0,row){
            f(j,0,col){
                int now = r[i] + c[j];
                if(arr[i][j] == '.') now--;
                ans = min(now,ans);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18
#define showarr for(i = 0; i < n; i++)for(j = 0; j < m; j++) {cout << arr[i][j];} cout << endl;

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin >> t;
    while(t--){
        int n , m ;
        cin>>n>>m;
        char arr[n][m];
        f(i,0,n){
            f(j,0,m){
                cin >> arr[i][j];
            }
        }
        int ma = 0, pos = 0;
        f(i,0,m){
            int cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
//            watch(cnt);
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
//        watch(ma); watch(pos);
        }

        int ans = 0; int cnt =0;
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') cnt++;
            arr[j][pos] = '*';
        }
        ans += cnt;
        ma = 0;pos = 0;
        f(i,0,n){
            int cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        cnt = 0;
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') cnt++;
            arr[pos][j] = '*';
        }
        ans += cnt;
        cout << ans << endl;

    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin>>t;
    while(t--){
        int row, col; cin >> row >> col;
        char arr[row][col];
        for(i = 0; i < row; i++)
            for(j = 0; j < col; j++)
                cin>>arr[i][j];

        int m = 0, pos = 0;
        for(i = 0; i < row; i++){
            int cnt = 0;
            for(j = 0; j < col; j++){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > m){
                pos = i;
                m = cnt;
            }
        }
        int ans = 0;
        for(i = 0; i < col; i++){
            if(arr[pos][i] == '.') ans++;
            arr[pos][i] = '*';
        }

        m = 0; pos = 0;
        for(j = 0; j < col; j++){
            int cnt = 0;
            for(i = 0; i < row; i++){
                if(arr[i][j] == '*') cnt++;
            }
            if(cnt > m){
                pos = j;
                m = cnt;
            }
        }
        for(i = 0; i < row; i++){
            if(arr[i][pos] == '.') ans++;
            arr[i][pos] = '*';
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18
#define showarr for(i = 0; i < n; i++)for(j = 0; j < m; j++) {cout << arr[i][j];} cout << endl;

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin >> t;
    while(t--){
        int n , m ;
        cin>>n>>m;
        char arr[n][m];
        f(i,0,n){
            f(j,0,m){
                cin >> arr[i][j];
            }
        }
        int ma = 0, pos = 0;
        f(i,0,m){
            int cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
//            watch(cnt);
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
//        watch(ma); watch(pos);
        }

        int ans = 0; int cnt =0;
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') cnt++;
            arr[j][pos] = '*';
        }
        ans += cnt;
        ma = 0;
        f(i,0,n){
            int cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        cnt = 0;
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') cnt++;
            arr[pos][j] = '*';
        }
        ans += cnt;
        cout << ans << endl;
//                for(i = 0; i < n; i++){
//            for(j = 0; j < m; j++)
//                cout << arr[i][j];
//            cout <<endl;
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18
#define showarr for(i = 0; i < n; i++)for(j = 0; j < m; j++) {cout << arr[i][j];} cout << endl;

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin >> t;
    while(t--){
        ll n , m ;
        cin>>n>>m;
        char arr[n][m];
        f(i,0,n){
            f(j,0,m){
                cin >> arr[i][j];
            }
        }
        ll ma = 0, pos = 0;
        f(i,0,m){
            ll cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
//            watch(cnt);
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
//        watch(ma); watch(pos);
        }

        ll ans = 0;
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') ans++;
            arr[j][pos] = '*';
        }
        ma = 0;pos = 0;
        f(i,0,n){
            ll cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') ans++;
            arr[pos][j] = '*';
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18
#define showarr for(i = 0; i < n; i++)for(j = 0; j < m; j++) {cout << arr[i][j];} cout << endl;

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin >> t;
    while(t--){
        ll n , m ;
        cin>>n>>m;
        char arr[n][m];
        f(i,0,n){
            f(j,0,m){
                cin >> arr[i][j];
            }
        }
        ll ma = 0, pos = 0;
        f(i,0,m){
            int cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
//            watch(cnt);
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
//        watch(ma); watch(pos);
        }

        ll ans = 0;
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') ans++;
            arr[j][pos] = '*';
        }
        ma = 0;pos = 0;
        f(i,0,n){
            int cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') ans++;
            arr[pos][j] = '*';
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define pcase cout<<"Case "<<++cs<<": ";
#define pb push_back
#define endl "\n";
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define f(i,st,n) for(i = st; i < n; i++)
#define vscan f(i,0,n){cin >> in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define inf 9e18
#define ninf -9e18
#define showarr for(i = 0; i < n; i++)for(j = 0; j < m; j++) {cout << arr[i][j];} cout << endl;

int main()
{
    int i = 0, j = 0, t, cs = 0, in;
    cin >> t;
    while(t--){
        ll n , m ;
        cin>>n>>m;
        char arr[n][m];
        f(i,0,n){
            f(j,0,m){
                cin >> arr[i][j];
            }
        }
        if(m >= n){
        ll ma = 0, pos = 0;
        f(i,0,m){
            ll cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }

        ll ans = 0;
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') ans++;
            arr[j][pos] = '*';
        }
        ma = 0;pos = 0;
        f(i,0,n){
            ll cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') ans++;
            arr[pos][j] = '*';
        }
        cout << ans << endl;}
        else{
            ll ans = 0, pos = 0;
        ll ma = 0;pos = 0;
        f(i,0,n){
            ll cnt = 0;
            f(j,0,m){
                if(arr[i][j] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        for(j = 0; j < m; j++){
            if(arr[pos][j] == '.') ans++;
            arr[pos][j] = '*';
        }
    ma = 0, pos = 0;
        f(i,0,m){
            ll cnt = 0;
            f(j,0,n){
                if(arr[j][i] == '*')
                    cnt++;
            }
            if(cnt > ma) pos = i;
            ma = max(cnt,ma);
        }
        for(j = 0; j < n; j++){
            if(arr[j][pos] == '.') ans++;
            arr[j][pos] = '*';
        }
        cout << ans << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{

	int q;cin>>q;
	for(int i=0;i<q;i++)
	{
		int r,c;
		cin>>r>>c;char p[r][c];
		map<int,int> m,v;int count=0,cnt=0;
		for(int j=0;j<r;j++)
		{
			for(int k=0;k<c;k++)
			{
				cin>>p[j][k];
				//cout<<p;
				if(p[j][k]=='*')
				{
					m[j]++;
				}
				if(p[j][k]=='*')
				{
					v[k]++;
				}
				if(m[j]==c)
				{
					count++;
				}
				if(v[k]==r)
				{
					cnt++;
				}
			}
			//cout<<endl;
		}
		int b=-1,s=-1;
		if(count*cnt==0)
		{
			int min1=0,min2=0;
				if(count==0)
				{
					for(auto i:m)
					{
						if(i.second>min1)
						{
							min1=i.second;
							b=i.first;
						}
					}
					min1=c-min1;
				}
				if(cnt==0)
				{
					for(auto i:v)
					{
						if(i.second>min2)
						{
							min2=i.second;
							s=i.first;
						}
					}
					min2=r-min2;
				}
				if(p[b][s]=='.' && count==0 && cnt==0)
				{
					cout<<min1+min2-1<<endl;
				}else
				{
					cout<<min1+min2<<endl;
				}

		}else if(count*cnt!=0)
		{
			cout<<"0"<<endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
char st[107][107];
int  n, m, cnt, flag;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)  scanf("%s",st[i]);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(st[i][j] == '*'){
                if(st[i+1][j]=='.') flag=1;
                if(st[i-1][j]=='.') flag=1;
                if(st[i][j+1]=='.') flag=1;
                if(st[i][j-1]=='.') flag=1;
            }
            if(flag == 1) break;
        }
        if(flag == 1) break;
    }
    if(flag == 1) printf("NO\n");
    else  printf("YES\n");

    return 0;
}


#include<iostream>
#include<cstring>
#include<stdio.h>
#define maxn 1005
using namespace std;
char a[maxn][maxn],b[maxn][maxn];
int d[8][2]={{1,0},{-1,0},{0,-1},{0,1},{1,1},{1,-1},{-1,1},{-1,-1}};
int main()
{
   int n,m;
    while(cin>>n>>m)
    {
        memset(a,'0',sizeof(a));
        memset(b,'0',sizeof(b));
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='*')
                    b[i][j]='*';
                if(a[i][j]=='.')
                    a[i][j]='0';
            }
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
            {
                if(a[i][j]=='*')
                {
                   for(int i=0;i<8;i++)
                   {
                       int newi=i+d[i][0];
                       int newj=j+d[i][1];
                       if(newi>=1&&newi<=n&&newj>=1&&newj<=m)
                        b[newi][newj]+=1;
                   }
                }
            }
            int flag=1;
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
                {
                    if(a[i][j]!=b[i][j])
                    {
                        flag=0;
                        break;
                    }
                }
                if(flag) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<stdio.h>
#define maxn 1005
using namespace std;
char a[maxn][maxn],b[maxn][maxn];
int main()
{
   int n,m;
    while(cin>>n>>m)
    {
        memset(a,'0',sizeof(a));
        memset(b,'0',sizeof(b));
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='*')
                    b[i][j]='*';
                if(a[i][j]=='.')
                    a[i][j]='0';
            }
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
            {
                if(a[i][j]=='*')
                {
                    b[i-1][j]+=1;
                    b[i+1][j]+=1;
                    b[i][j+1]+=1;
                    b[i][j-1]+=1;
                    b[i+1][j+1]+=1;
                    b[i+1][j-1]+=1;
                    b[i-1][j+1]+=1;
                    b[i-1][j-1]+=1;
                }
            }
            int flag=1;
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
                {
                    if(a[i][j]!=b[i][j])
                    {
                        flag=0;
                        break;
                    }
                }
                if(flag) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 1005
using namespace std;
char a[maxn][maxn],b[maxn][maxn];
int main()
{
   int n,m;
    while(cin>>n>>m)
    {
        memset(a,'0',sizeof(a));
        memset(b,'0',sizeof(b));
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='*')
                    b[i][j]='*';
                if(a[i][j]=='.')
                    a[i][j]='0';
            }
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
            {
                if(a[i][j]=='*')
                {
                    b[i-1][j]+=1;
                    b[i+1][j]+=1;
                    b[i][j+1]+=1;
                    b[i][j-1]+=1;
                    b[i+1][j+1]+=1;
                    b[i+1][j-1]+=1;
                    b[i-1][j+1]+=1;
                    b[i-1][j-1]+=1;
                }
            }
            int flag=1;
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++)
                {
                    if(a[i][j]!=b[i][j])
                    {
                        flag=0;
                        break;
                    }
                }
                if(flag) cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vpi vector< pair<int,int> >
#define vi vector<int>
#define vl vector<long long>
#define vpl vector< pair<ll,ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() {
	fast
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	ll cntd =0,cntb = 0,cntn = 0;
	for(ll i =0;i<n;i++)
	{
	    for(ll j =0;j<m;j++)
	    {
	        cin>>a[i][j];
	        if(a[i][j]=='.') cntd++;
	        else if(a[i][j]=='*') cntb++;
	        else cntn++;
	    }
	}
	    int flag;
       int ff=0;
    for(int i=0;i<m;++i){
      for(int j=0;j<n;++j){
        flag=0;
        if(a[i][j]>='1'&&a[i][j]<='9'||a[i][j]=='.'){
          if(a[i-1][j-1]=='*'&&i>=1&&j>=1)
             flag++;
          if(a[i-1][j]=='*'&&i>=1)
             flag++;
          if(a[i-1][j+1]=='*'&&i>=1)
             flag++;
          if(a[i+1][j+1]=='*')
             flag++;
          if(a[i][j-1]=='*'&&j>=1)
             flag++;
          if(a[i][j+1]=='*')
            flag++;
          if(a[i+1][j-1]=='*'&&j>=1)
            flag++;
          if(a[i+1][j]=='*')
            flag++;
          if(flag!=a[i][j]-'0'&&a[i][j]>='1'&&a[i][j]<='9'){
                 ff=1;
                 break;
        }
         if(flag!=0&&a[i][j]=='.'){
           ff=1;
           break;
         }
        }
      }
      if(ff==1)
        break;
    }
    if(ff==0)
       cout<<"YES"<<endl;
    if(ff==1)
       cout<<"NO"<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vpi vector< pair<int,int> >
#define vi vector<int>
#define vl vector<long long>
#define vpl vector< pair<ll,ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() {
	fast
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	ll cntd =0,cntb = 0,cntn = 0;
	for(ll i =0;i<n;i++)
	{
	    for(ll j =0;j<m;j++)
	    {
	        cin>>a[i][j];
	        if(a[i][j]=='.') cntd++;
	        else if(a[i][j]=='*') cntb++;
	        else cntn++;
	    }
	}
	if(cntd==n*m||cntb==n*m||cntn=='n*m')
	{
	    cout<<"YES";
	}
	else
	{
	    int flag =0;
	for(int i =0;i<n;i++)
	{
	    for(int j =0;j<m;j++)
	    {
	        if(a[i][j]=='*')
	        {
	            if(a[i][j-1]=='.'||a[i-1][j]=='.'||a[i+1][j]=='.'||a[i][j+1]=='.'||a[i-1][j-1]=='.'||a[i-1][j+1]=='.'||a[i+1][j-1]=='.'||a[i+1][j+1]=='.')
	            {
	                flag = 1;
	                break;
	            }
	        }
	        else if(a[i][j]>=1&&a[i][j]<=8)
	        {
	            ll cnt = 0;
	            if(a[i-1][j-1]=='*') cnt++;
	            if(a[i-1][j]=='*') cnt++;
	            if(a[i-1][j+1]=='*') cnt++;
	            if(a[i+1][j-1]=='*') cnt++;
	            if(a[i+1][j]=='*') cnt++;
	            if(a[i+1][j+1]=='*') cnt++;
	            if(a[i][j-1]=='*') cnt++;
	            if(a[i-1][j+1]=='*') cnt++;

	            if(cnt!=a[i][j])
	            {
	                flag =1;
	                break;
	            }
	        }
	    }
	}
	if(flag) cout<<"NO";
	else cout<<"YES";
	}
	return 0;
}