#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define sz(x) ((int)(x).size())

#define MULTIPLE_CASES

const ll MOD = 1e9+7;

void solve()
{
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    ll ans = 1;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        for(char c : s)
        {
            if(c == '#')
            {
                cnt++;
                ans = (ans * 2) % MOD;
            }
        }
    }
    if(cnt == n*m) ans = (ans - 1 + MOD) % MOD;
    cout << ans << "\n";
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    #ifdef MULTIPLE_CASES
    int t;
    cin >> t;
    for(int i = 0; i < t; ++i)
    {
        solve();
    }
    #else
    solve();
    #endif
}