#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

class Main {
    int H, W, K;
    vector<string> S;
    void input() {
        cin >> H >> W;
        S.resize(H);
        K = 0;
        REP(i, H) {
            cin >> S[i];
            REP(j, W) {
                if (S[i][j] == '.') ++K;
            }
        }
    }
    void output() {
        vector<vector<ll>> memo(H, vector<ll>(W));
        REP(i, H) {
            REP(j, W) {
                int o = j;
                while (j < W && S[i][j] == '.') ++j;
                FOR(k, o, j) {
                    memo[i][k] += j - o;
                }
            }
        }
        REP(j, W) {
            REP(i, H) {
                int o = i;
                while (i < H && S[i][j] == '.') ++i;
                FOR(k, o, i) {
                    memo[k][j] += i - o - 1;
                }
            }
        }
        mint res = 0;
        vector<mint> pow(K + 1);
        pow[0] = 1;
        REP(i, K) {
            pow[i + 1] = mint(2) * pow[i];
        }
        REP(i, H) {
            REP(j, W) {
                if (S[i][j] == '#') continue;
                res += pow[K] - pow[K - memo[i][j]];
            }
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    Main();

    return 0;
}

#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, a, b;

void solve(){
    cin>>n>>a>>b;
    if(b > a) swap(a, b);
    ll fr = (n - a + 1)*(n - a + 1) % mod;
    ll sc = (n - b + 1)*(n - b + 1) % mod;
    ll mn = min(a + b - 1, n); 
    ll sub = (a - mn + mod) % mod * ((mn + a - 2*n%mod - 1 + 3LL*mod)%mod) % mod * (a - mn + mod) % mod * ((mn + a - 2*n - 1 + 3LL*mod)%mod) % mod;
    sub += (-2*(a - b + 1)*((a - n - 1 + 2*mod)%mod )%mod) * ((a - mn + mod)%mod) % mod * ((mn + a - 2* n -1 + 3LL*mod)%mod) % mod;
    sub %= mod;
    sub += (a - b + 1) * (a - b + 1) % mod * fr % mod;
    sub %= mod;
    cerr<<fr<<" "<<sc<<" "<<sub<<endl;
    ll ans = (fr*sc%mod - sub + mod) % mod;
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    int t;
    cin>>t;

    while(t--) solve();
    

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}