#include "bits/stdc++.h"
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2")
using namespace std;
using ll = int64_t;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    const int mod = 1e9+7;
    int t; cin >> t;
    while (t--) {
        int n, m, ans = 1; cin >> n >> m;
        bool zero = false;
        for (int i = 0; i < n; ++i) {
            string s; cin >> s;
            for (auto c : s) {
                if (c == '#') ans = (ans * 2)%mod;
                else zero = true;
            }
        }
        if (!zero) ans = (ans + mod - 1)%mod;
        cout << ans << '\n';
    }
}