#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll mod = 998244353;
const int M = 2e5+5;
ll a[M],cs[M],val[M],ncr[500][500],tot[500];
void pre()
{
	ncr[0][0]=1;
	for(int i=1;i<500;i++)
	{
		ncr[i][0] = 1;
		for(int j=1;j<=i;j++)
			ncr[i][j] = (ncr[i-1][j-1]+ncr[i-1][j])%mod;
	}
}
ll power(ll a,ll b)
{
	ll val = 1;
	while(b)
	{
		if(b%2)
			val = (val*a)%mod;
		a = (a*a)%mod;
		b/=2;
	}
	return val;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	int n,k;
	cin>>n>>k;
	ll sum = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum = (sum+a[i])%mod;
		val[i] = 1;
	}
	for(int j=1;j<=k;j++)
	{
		ll res = 0;
		for(int i=1;i<=n;i++)
		{
			val[i]=(val[i]*a[i])%mod;
			res = (res+val[i])%mod;
		}
		tot[j] = res;
	}
	tot[0] = n;
	for(int i=1;i<=k;i++)
	{
		ll ans = 0;
		ll c = 1;
		for(int j=0;j<=i;j++)
		{
			ll z = ncr[i][j];
			z = (z*tot[i-j])%mod;
			z = (z*tot[j])%mod;
			ans = (ans + z)%mod;
			if(j)
				c=(c*2)%mod;
		}
		ans = (ans-(c*tot[i])%mod+mod)%mod;
		ans = (ans*power(2,mod-2))%mod;
		cout<<ans<<"\n";
	}
	return 0;
}
// Author: wlzhouzhuan
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

const int N = 1005;
const int mod = 998244353;

char a[N][N];
int pw[N * N];
int A[N], B[N], C[N];
int n, m;

int main() {
  scanf("%d%d", &n, &m);
  pw[0] = 1;
  for (int i = 1; i <= n * m; i++) {
    pw[i] = 2 * pw[i - 1] % mod;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
    for (int j = 1; j <= m; j++) {
      int pos = i + j;
      if (a[i][j] == 'B') A[pos]++;
      if (a[i][j] == 'R') B[pos]++;
      if (a[i][j] == '.') C[pos]++;
    }
  }
  int ans = 1;
  for (int i = 2; i <= n + m; i++) {
    if (A[i] && B[i]) return puts("0") & 0;
    if (!A[i] && !B[i]) ans = 2ll * ans % mod;
  }
  printf("%d\n", ans);
  return 0;
}