/*
 * 答え見た
 * https://atcoder.jp/contests/keyence2021/submissions/19465975
 */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int mod = 998244353;
char grid[5005][5005];
ll   dp[5005][5005];

// (x^y) % mod
long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    long long res = modpow(x, y / 2);
    return res * res % mod;
}

int main(){
  ll h, w, k;
  cin >> h >> w >> k;
  rep(i, k){
	ll x, y;
	char c;
	cin >> x >> y >> c;
	x--; y--;
	grid[x][y] = c;
  }
  // 開始マスの初期値は 3^(h*w-k)
  dp[0][0] = modpow(3, h*w-k);
  ll div_three = modpow(3, mod-2);  // 1/3 を表す
  rep(i, h){
	rep(j, w){
	  // 空白マスの場合
	  // 2/3 を掛ける
	  if (!grid[i][j]){
		ll plus = (dp[i][j] * div_three) % mod;
		if (j + 1 != w)
		{
			dp[i][j + 1] += plus;
			dp[i][j + 1] %= mod;
		}
		if (i + 1 != h)
		{
			dp[i + 1][j] += plus;
			dp[i + 1][j] %= mod;
		}
		if (j + 1 != w)
		{
			dp[i][j + 1] += plus;
			dp[i][j + 1] %= mod;
		}
		if (i + 1 != h)
		{
			dp[i + 1][j] += plus;
			dp[i + 1][j] %= mod;
		}
	  }
	  else
	  {
	  	if (grid[i][j] == 'R')
	  	{
	  		if (j + 1 != w)
	  		{
	  			dp[i][j + 1] += dp[i][j];
	  			dp[i][j + 1] %= mod;
	  		}
	  	}
	  	if (grid[i][j] == 'D')
	  	{
	  		if (i + 1 != h)
	  		{
	  			dp[i + 1][j] += dp[i][j];
	  			dp[i + 1][j] %= mod;
	  		}
	  	}
	  	if (grid[i][j] == 'X')
	  	{
	  		if (j + 1 != w)
	  		{
	  			dp[i][j + 1] += dp[i][j];
	  			dp[i][j + 1] %= mod;
	  		}
	  		if (i + 1 != h)
	  		{
	  			dp[i + 1][j] += dp[i][j];
	  			dp[i + 1][j] %= mod;
	  		}
	  	}
	  }
	}
  }
  cout << dp[h - 1][w - 1] << endl;
}

#include <bits/stdc++.h>

#define int long long
using namespace std;

const int MAX = 5005, MOD = 998244353;
int m, n, k, f[MAX][MAX];
char a[MAX][MAX];

int mul(int x, int k) {
    if (k == 0)
        return 1;
    int tmp = mul(x, k / 2);
    if (k % 2 == 0)
        return tmp * tmp % MOD;
    return tmp * tmp % MOD * x % MOD;
}

int32_t main() {
#ifdef ACM
    freopen("input", "r", stdin);
#endif
    cin >> m >> n >> k;
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= n; j++)
            a[i][j] = '*';
    int x, y;
    char c;
    for (int i = 0; i < k; i++) {
        cin >> x >> y >> c;
        a[x][y] = c;
    }
    f[1][1] = 1;
    int rev3 = mul(3, MOD - 2);
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= n; j++) {
            if (i + j == 2)
                continue;
            if (i > 1) {
                if (a[i - 1][j] == 'D' || a[i - 1][j] == 'X')
                    f[i][j] = (f[i][j] + f[i - 1][j]) % MOD;
                if (a[i - 1][j] == '*')
                    f[i][j] = (f[i][j] + f[i - 1][j] * 2 % MOD * rev3) % MOD;
            }
            if (j > 1) {
                if (a[i][j - 1] == 'R' || a[i][j - 1] == 'X')
                    f[i][j] = (f[i][j] + f[i][j - 1]) % MOD;
                if (a[i][j - 1] == '*')
                    f[i][j] = (f[i][j] + f[i][j - 1] * 2 % MOD * rev3) % MOD;
            }
        }
    cout << f[m][n] * mul(3, m * n - k) % MOD;
}