#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>

#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long  long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;

const int inf = 1e9 + 228;
const ll infll = 1e18;
const ll MOD = 1e9 + 7;
//static const int maxn = 1e6 + 228;
const ld eps = 1e-9;
const int K = 31;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1 << 18);
const ld PI = 3.1415926535;

void fast_io() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//     freopen("INPUT.TXT", "r", stdin);
//     freopen("OUTPUT.TXT", "w", stdout);
}

const int maxn = 2e5 + 3;

int kek[maxn];
int lol[maxn][301];
int lol2[maxn][301];

int fac[301];
int rfac[301];

int binpow(int n, int k) {
    if (!k)
        return 1;
    else if (k & 1)
        return binpow(n, k - 1) * n % MOD2;
    int b = binpow(n, k / 2);
    return b * b % MOD2;
}

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> kek[i];
    fac[0] = rfac[0] = 1;
    for (int i = 1; i <= k; i++) {
        fac[i] = fac[i - 1] * i;
        fac[i] %= MOD2;
        rfac[i] = binpow(fac[i], MOD2 - 2);
    }
    for (int i = 0; i < n; i++) {
        lol[i][0] = 1;
        for (int j = 1; j <= k; j++) {
            lol[i][j] = lol[i][j - 1] * kek[i] % MOD2;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            lol[i][j] = lol[i][j] * rfac[j] % MOD2;
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j <= k; j++) {
            lol2[i][j] = lol2[i + 1][j] + lol[i][j];
            if (lol2[i][j] >= MOD2)
                lol2[i][j] -= MOD2;
        }
    }
    for (int i = 1; i <= k; i++) {
        int ans = 0;
        for (int j = 0; j <= i; j++) {
            ans += lol2[0][j] * lol2[0][i - j];
            ans %= MOD2;
        }
        ans *= fac[i];
        ans %= MOD2;
        ans *= binpow(2, MOD2 - 2);
        ans %= MOD2;
        int abc = binpow(2, i - 1);
        for (int j = 0; j < n; j++) {
            ans -= lol[j][i] * fac[i] % MOD2 * abc % MOD2;
            ans += MOD2;
            if(ans >= MOD2)
                ans -= MOD2;
        }
        cout << ans << endl;
    }
}

signed main() {
    fast_io();
    srand(time(NULL));
    cout << fixed << setprecision(10);
    int q = 1;
//    cin >> q;
    while (q--)
        solve();
}
#include <bits/stdc++.h>
using namespace std;

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define rep1(a, b, c)  for(int a = (b); a < (c); ++a)
#define each(a, b)     for(auto& a : b)

#define sz(x)       (int)(x).size()
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(), (a).rend()

#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cout << #x << " = " << x << endl;
#define vt vector
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bitcnt(x) __builtin_popcount(x)

using ll = long long;

const int inf = (int)1e9 + 5;
const ll infl = (ll)1e18 + 5;
const int mod = 1e9 + 7;

int d[2000][2000][4];

ll go(int b){
	ll ans = 1;
	ll t = 2;
	while(b){
		if(b&1) ans = (ans*t)%mod;
		b >>= 1; t = (t*t)%mod;
	}
	return ans;
}


void solve(){
	int h, w; cin >> h >> w;
	vt<string> s(h);
	each(x, s) cin >> x;
	ll t1 = 0;
	rep(x, h){
		int t = 0;
		rep(y, w){
			d[x][y][0] = t;
			if(s[x][y] == '.') ++t, ++t1;
			else t = 0;
		}
	}
	rep(x, h){
		int t = 0;
		for(int y = w-1; ~y; --y){
			d[x][y][1] = t;
			if(s[x][y] == '.') ++t;
			else t = 0;
		}
	}
	rep(y, w){
		int t = 0;
		rep(x, h){
			d[x][y][2] = t;
			if(s[x][y] == '.') ++t;
			else t = 0;
		}
	}
	rep(y, w){
		int t = 0;
		for(int x = h-1; ~x; --x){
			d[x][y][3] = t;
			if(s[x][y] == '.') ++t;
			else t = 0;
		}
	}
	ll t2 = go(t1);
	ll ans = 0;
	rep(i, h) rep(j, w){
		if(s[i][j] == '#') continue;
		int t = 0;
		rep(k, 4) t += d[i][j][k];
		t += (s[i][j] == '.');
		ll t3 = go(t1-t);
		ans += t2 - t3;
	}
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << '\n';
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}