#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define si set<int>
#define usi unordered_set<int> 
#define msi multiset<int>
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define umi unordered_map<int, int>
#define mmi multimap<int, int>
#define mi map<int, int>
#define rev(i,a,b) for(int i = a;i>=b;i--)
#define ummi unordered_multimap<int, int>
#define vpi vector<pair<int, int> >
#define int long long

using namespace std;

const int M = 1e9 + 7;

int32_t main(){
	int t;
	cin >> t;
	//t = 1;
	while(t--){
		int n, m;
		cin >> n >> m;
		int ct= 1;
		char a[n][m];
		bool flag = false;
		rep(i,0,n){
			rep(j,0,m){
				cin >> a[i][j];
				if(a[i][j] == '#'){
					ct = (ct*2)%M;

				}
				else{
					flag = true;
				}
			}
		}
		if(flag){
			cout << ct << endl;
		}
		else{
			ct = (ct-1)%M;
			cout << ct <<endl;
		}
	}
}