#include <iostream>
using namespace std;

int main() {
	// your code goes here
	    ios_base::sync_with_stdio(false);

	int t;
	cin>>t;
	int M=1e9+7;
	
	while(t--){
	    
	int ans=1;    
	    int n,m;cin>>n>>m;
	    
	    int l = n*m, s=0;
	    while(l--){
	        char j;cin>>j;
	        if(j=='#')ans%=M,s++,ans*=2;
	        
	        
	    }
	    
	    if(s==n*m)ans--;
	    ans%=M;
	    cout<<ans<<endl;
	}
	return 0;
}
