#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 998244353;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll modinv(ll n) {
    return powmod(n, P - 2);
}

int dp[5000][5000];
char d[5000][5000];

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

    int h, w, k;
    cin >> h >> w >> k;

    for (int l = 0; l < k; l++) {
        int i, j;
        char c;
        cin >> i >> j >> c;
        i--; j--;

        d[i][j] = c == 'R' ? 1 : c == 'D' ? 2 : 3;
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ll t = 0;
            if (i == 0 && j == 0) {
                t = 1;
            } else {
                if (j > 0 && d[i][j - 1] != 2) {
                    int s = 1;
                    if (d[i][j - 1] == 0) s = 2;
                    t += dp[i][j - 1] * s;
                }
                if (i > 0 && d[i - 1][j] != 1) {
                    int s = 1;
                    if (d[i - 1][j] == 0) s = 2;
                    t += dp[i - 1][j] * s;
                }
            }
            if (d[i][j] != 0) t *= 3;
            dp[i][j] = t % P;
        }
    }

    ll r = dp[h - 1][w - 1];
    int t = h * w - k - (h + w - 1);
    if (d[h - 1][w - 1] == 0) r = r * 3 % P;
    if (t > 0) {
        r = r * powmod(3, t) % P;
    } else if (t < 0) {
        r = r * powmod(modinv(3), -t) % P;
    }

    cout << r << endl;

    //通らない場所の塗り方も関係するじゃん！
    //通るマスの数はH+W-1

    return 0;
}
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n,k,A[MAXN],C[302][302],mod=998244353,sum[MAXN],ans[302],co[MAXN];
ll qexp(ll x,ll e){
	ll sum=1;
	for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;
	return sum;
}
int main(){
	FAST
	cin>>n>>k;
	FOR(i,1,n)cin>>A[i];
	FOR(i,0,300) C[i][0]=1;
	FOR(i,1,300) FOR(j,1,300) C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
	FOR(i,1,n){
		ll co = 1;
		FOR(j,0,k){
			sum[j] += co, sum[j] %= mod;
			co *= A[i], co %= mod;
		}
	}
	fill(co,co+MAXN,1);
	FOR(i,1,k){
		ll ans = 0;
		FOR(j,0,i){
			ans += sum[j] * sum[i-j] % mod * C[i][j] % mod, ans %= mod;
		}
		FOR(z,1,n){
			co[z] *= A[z] * 2 % mod, co[z] %= mod;
			ans -= co[z], ans += mod, ans %= mod;
		}
		ans *= qexp(2, mod-2), ans %= mod;
		cout<<ans<<'\n';
	}
}
