#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
int tt;string s;int p=1e9+7;

void solve(){
	int n,m,k=0,ans=1;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char c;cin>>c;
			if(c=='#'){ans=(ans*2)%p;k++;}
		}
	}
	if(k==m*n)ans--;
	cout<<ans<<'\n';
}
	

signed main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //prepare();
    cin>>tt;
    while(tt--)
    solve();
}