#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
//#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 5005
#define MOD 998244353

ll dp[SIZE][SIZE];
char base_map[SIZE][SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;

}


ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}


int main(){

	ll H,W,K;
	scanf("%lld %lld %lld",&H,&W,&K);

	for(ll row = 0; row < H; row++){
		for(ll col = 0; col < W; col++){

			base_map[row][col] ='@';

			dp[row][col] = 0;
		}
	}

	int tmp_row,tmp_col;
	char buf[2];

	for(ll i = 0; i < K; i++){

		scanf("%d %d %s",&tmp_row,&tmp_col,buf);
		tmp_row--;
		tmp_col--;

		base_map[tmp_row][tmp_col] = buf[0];
	}

	ll MULT = 2*mod_inverse(3,MOD);
	MULT %= MOD;

	dp[0][0] = 1;

	for(ll row = 0; row < H; row++){
		for(ll col = 0; col < W; col++){
			if(row-1 >= 0 && base_map[row-1][col] != 'R'){

				if(base_map[row-1][col] == '@'){

					dp[row][col] += dp[row-1][col]*MULT;
					dp[row][col] %= MOD;

				}else{

					dp[row][col] += dp[row-1][col];
					dp[row][col] %= MOD;
				}
			}

			if(col-1 >= 0 && base_map[row][col-1] != 'D'){

				if(base_map[row][col-1] == '@'){

					dp[row][col] += dp[row][col-1]*MULT;
					dp[row][col] %= MOD;

				}else{

					dp[row][col] += dp[row][col-1];
					dp[row][col] %= MOD;
				}
			}

		}
	}

	printf("%lld\n",(dp[H-1][W-1]*mod_pow(3,H*W-K,MOD))%MOD);

	return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define dbg3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;
#define nl() cout << "========================================" << endl;
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }
#define yn { puts("Yes"); } else{ puts("No"); } // 使い方: if (条件) yn; 

// 拡張ユークリッドの互除法
ll extGcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1; y = 0;
        return a;
    }
    ll s, t;
    ll d = extGcd(b, a % b, s, t);
    x = t;
    y = s - a / b * x;
    return d;
}

// aの逆元(mod p)
ll modinv(ll a, ll p) {
    ll x, y;
    extGcd(a, p, x, y);
    while (x < 0) x += p;
    x %= p;
    return x;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;

        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const ll MOD = 998244353;

int main() {
    ll H, W, K; cin >> H >> W >> K;
    vector<vc> G(H, vc(W, '?'));
    rep(i, K) {
        int x, y; cin >> x >> y; char c; cin >> c;
        x--; y--;
        G[x][y] = c;
    }

    vvl dp(H, vl(W, 0));
    dp[0][0] = 1;

    rep(i, H) {
        rep(j, W) {
            switch (G[i][j]) {
                case 'D':
                    if (i + 1 < H) {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }

                    break;
                case 'R':
                    if (j + 1 < W) {
                        dp[i][j + 1] += dp[i][j];
                        dp[i][j + 1] %= MOD;
                    }

                    break;
                case 'X':
                    if (i + 1 < H) {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }
                    if (j + 1 < W) {
                        dp[i][j + 1] += dp[i][j];
                        dp[i][j + 1] %= MOD;
                    }

                    break;
                default:
                    if (i + 1 < H) {
                        dp[i + 1][j] += 2 * dp[i][j] * modinv(3, MOD);
                        dp[i + 1][j] %= MOD;
                    }
                    if (j + 1 < W) {
                        dp[i][j + 1] += 2 * dp[i][j] * modinv(3, MOD);
                        dp[i][j + 1] %= MOD;
                    }
            }
        }
    }

    ll res = modpow(3, H * W - K, MOD) * dp[H - 1][W - 1] % MOD;
    cout << res << endl;
}
