#include <bits/stdc++.h>
#define maxn 2010
#define mod (int)(1e9+7)
using namespace std;

int n, m;
char s[maxn][maxn];

int main()
{
	int t; cin >> t;
	while (t -- )
	{
		cin >> n >> m;
		for (int i = 1; i <= n; i ++ ) scanf("%s", s[i] + 1);
		int ans = 1, cnt = 0;
		for (int i = 1; i <= n; i ++ )
			for (int j = 1; j <= m; j ++ )
				if (s[i][j] == '#')
					ans = 1ll * ans * 2 % mod, cnt ++ ;
		if (cnt == n * m) ans -- ;
		printf("%d\n", ans);
	}
}