#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
int n,m,K;
char s[10];
int d[5010][5010],dp[5010][5010];
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int iv[5],tmp;
int ksm(int x,int y) {
	int res=1;
	while (y) {
		if (y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod; y>>=1;
	} return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n),read(m),read(K); int x,y;
	for (int i=1;i<=K;i++) {
		read(x),read(y); scanf("%s",s+1);
		if (s[1]=='R') d[x][y]=1;
		else if (s[1]=='D') d[x][y]=2;
		else d[x][y]=3;
	}
	iv[0]=iv[1]=1; for (int i=2;i<=3;i++) iv[i]=(ll)(mod-mod/i)*iv[mod%i]%mod;
	dp[1][1]=1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			if (i==n&&j==m) { printf("%lld\n",(ll)dp[n][m]*ksm(3,n*m-K)%mod); return 0; }
			for (int k=1;k<=3;k++) {
				if (d[i][j]&&d[i][j]!=k) continue;
				if (!d[i][j]) tmp=iv[3]; else tmp=1;
				if (k!=2) update(dp[i][j+1],(ll)dp[i][j]*tmp%mod);
				if (k!=1) update(dp[i+1][j],(ll)dp[i][j]*tmp%mod);
			}
		}
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Integer overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

long long mod_pow(long long x, long long y, long long M){
    if(y == 0){
        return 1;
    }
    if(y & 1){
        return mod_pow(x, y - 1, M) * x % M;
    }
    long long t = mod_pow(x, y / 2, M);
    return t * t % M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,K;
    cin >> H >> W >> K;
    vvc C(H,vc(W,'O'));
    rep(i,K){
        int h,w;
        char c;
        cin >> h >> w >> c;
        h--;w--;
        C[h][w]=c;
    }
    vvl dp(H+1,vl(W+1,0));
    dp[0][0]=mod_pow(3,H*W-K,MOD2);
    ll i3=mod_pow(3,MOD2-2,MOD2);
    rep(i,H){
        rep(j,W){
            if(C[i][j]=='O'){
                dp[i][j+1]+=2*i3*dp[i][j];
                dp[i+1][j]+=2*i3*dp[i][j];
            }
            else if(C[i][j]=='X'){
                dp[i][j+1]+=dp[i][j];
                dp[i+1][j]+=dp[i][j];
            }
            else if(C[i][j]=='D'){
                dp[i+1][j]+=dp[i][j];
            }
            else if(C[i][j]=='R'){
                dp[i][j+1]+=dp[i][j];
            }
            dp[i+1][j]%=MOD2;
            dp[i][j+1]%=MOD2;
        }
    }
    cout << dp[H-1][W-1] << endl;
}