#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void re(int &x){scanf("%d",&x);}
void re(int &x,int &y){scanf("%d %d",&x,&y);}
void re(ll &x){scanf("%lld",&x);}
void re(ll &x,ll &y){scanf("%lld %lld",&x,&y);}
void re(double &x){scanf("%lf",&x);}
void re(double &x,int &y){scanf("%lf %lf",&x,&y);}
using namespace std;
const int N=1e5+5;
const int mod=998244353;

string s[N];
char boom[N];
int main()
{
    int n,m;re(n,m);
    rep(i,0,n+m-2) boom[i]='.';
    rep(i,0,n-1) cin>>s[i];
    rep(i,0,n-1)
    {
        rep(j,0,m-1)
        {
            if(s[i][j]=='R'&&boom[i+j]!='B') boom[i+j]='R';
            else if(s[i][j]=='B'&&boom[i+j]!='R') boom[i+j]='B';
            else if(s[i][j]=='.') continue;
            else
            {
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans=1;
    rep(i,0,n+m-2)
    {
        if(boom[i]=='.') ans=(ans*2)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

// editorial
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

typedef long long ll;
const ll mod = 998244353;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    vector<ll> fact(k+1, 1);
    for(int i = 1; i <= k; i++) fact[i] = fact[i-1]*i%mod;
    vector<ll> invf(k+1, 1);
    for(int i = 1; i <= k; i++) invf[i] = modpow(fact[i], mod-2, mod);
    vector<ll> sum(k+1, 0);
    sum[0] = n;
    vector<ll> powers(n, 1);
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            powers[j] = powers[j]*v[j]%mod;
            (sum[i] += powers[j]*invf[i]%mod) %= mod;
        }
    }
    const ll invtwo = modpow(2, mod-2, mod);
    vector<ll> fpowers(n, 1);
    for(int i = 1; i <= k; i++){
        ll tmp = 0, sub = 0;
        for(int j = 0; j <= i; j++){
            (tmp += sum[j]*sum[i-j]%mod) %= mod;
        }
        (tmp *= fact[i]) %= mod;
        for(int j = 0; j < n; j++){
            fpowers[j] = fpowers[j]*2*v[j]%mod;
            (sub += fpowers[j]) %= mod;
        }
        cout << (tmp-sub+mod)*invtwo%mod << endl;
    }
    return 0;
}