#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define mod 998244353
using namespace std;
template<class T, class U>
T &chmax(T &a, const U &b){ if(a < b) a = b; return a; }
template<class T, class U>
T &chmin(T &a, const U &b){ if(a > b) a = b; return a; }
int main(){
  int h,w;
  cin >> h >> w;
  vector<string> board(h);
  rep(i, h) cin >> board[i];
  ll ans = 1;
  rep(i, w){
    int y = 0, x = i;
    int b = 0, r = 0, n = 0;
    while(y < h && x >= 0){
      if(board[y][x] == 'B') b++;
      if(board[y][x] == 'R') r++;
      if(board[y][x] == '.') n++;
      y++; x--;
    }
    if(b && r){
      cout << "0\n";
      return 0;
    }else if(!b && !r) (ans *= 2) %= mod;
  }
  for(int i = 1; i < h; i++){
    int y = i, x = w - 1;
    int b = 0, r = 0, n = 0;
    while(y < h && x >= 0){
      if(board[y][x] == 'B') b++;
      if(board[y][x] == 'R') r++;
      if(board[y][x] == '.') n++;
      y++; x--;
    }
    if(b && r){
      cout << "0\n";
      return 0;
    }else if(!b && !r) (ans *= 2) %= mod;
  }
  cout << ans << "\n";
}
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,k,x,y;

//moddivとnCkとgarner
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}

//nCk
vi mulmod(301);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<301;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
 
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}
 
ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}


int main(){
  ll ans=0;
  first_nCk();
  cin >> n >> k;
  k++;
  vi a(n);
  REP(i,n) cin>>a[i];
 
  vvi data(n, vi(k));
  vi tmsum(k); 
  for(ll i=0;i<n;i++){
    ll gege=1;
    ll ggg=1;
    for(ll j=0;j<k;j++){
      data[i][j]=gege;
      gege=a[i]*gege%MOD;
      tmsum[j]+=ggg;
      ggg=ggg*a[i]*2%MOD;
    }
  }
  
  for(ll j=0;j<k;j++)
    tmsum[j]%=MOD;
 
  vi datasum(k);
  for(ll i=0;i<n;i++){
    for(ll j=0;j<k;j++){
      datasum[j]+=data[i][j];
      datasum[j]%=MOD;
    }
  }
  
  for(ll i=1;i<k;i++){
    ans=0;
    ll tmp=MOD;
    for(ll j=0;j<i+1;j++){
      tmp=tmp+datasum[i-j]*datasum[j]%MOD*nCk(i,j)%MOD;
    }
    tmp=(tmp-tmsum[i])%MOD;
    cout<<(moddiv(tmp,2,MOD))<<endl;
  }
  return 0;
}