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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod = 1e9 + 7;

void solve() {
  int n, m;
  cin >> n >> m;

  bool zero{false};
  ll ans{1};
  rep(i, 0, n) rep(j, 0, m) {
      char c;
      cin >> c;
      if (c == '#') {
        ans = ans * 2LL % mod;
      } else {
        zero = true;
      }
    }

 if (!zero) --ans;
  cout << ans << '\n';
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  int tt;
  cin >> tt;
  while (tt--) solve();
}