#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 5e3; int n, m, k;
char mat[maxN][maxN + 1];

const lli mod = 998244353;

lli base;
lli solve1(int i = 0, int j = 0)
{
  if (i >= n || j >= m) return 0;
  if (i == n - 1 && j == m - 1) return 1;

  lli ans = 0;
  if (mat[i][j] == 'R')
    ans = (ans + solve1(i, j + 1)) % mod;
  else if (mat[i][j] == 'D')
    ans = (ans + solve1(i + 1, j)) % mod;
  else if (mat[i][j] == 'X')
    ans = (ans + solve1(i, j + 1) + solve1(i + 1, j)) % mod;
  else
    ans = 0;

  return ans;
}
lli memo[maxN][maxN];
lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = ans * x % mod;
    x = x * x % mod, y >>= 1LL;
  }
  return ans;
}
lli inv(lli x)
{
  return modPow(x, mod - 2);
}
lli pot[maxN*maxN + 1];
lli inv3;
lli solve2(int i = 0, int j = 0, int unknown = 0)
{
  if (i >= n || j >= m) return 0;
  if (i == n - 1 && j == m - 1) return pot[(n*m - k) - 0];
  lli &ans = memo[i][j];
  if (ans != -1) return ans;
  
  ans = 0;
  if (mat[i][j] == 'R')
    ans = solve2(i, j + 1, unknown);
  else if (mat[i][j] == 'D')
    ans = solve2(i + 1, j, unknown);
  else if (mat[i][j] == 'X')
  {
    ans = (solve2(i, j + 1, unknown) + solve2(i + 1, j, unknown)) % mod;
  }
  else
  {
    lli a = 2LL * solve2(i, j + 1, unknown + 1) % mod;
    lli b = 2LL * solve2(i + 1, j, unknown + 1) % mod;
    ans = (a + b) * inv3 % mod;
  }
  return ans;
}

int main()
{
  inv3 = inv(3);
  while (~scanf("%d %d %d", &n, &m, &k))
  {
    pot[0] = 1;
    for (int i = 1; i <= n*m; i++)
      pot[i] = 3LL * pot[i - 1] % mod;

    memset(mat, '.', sizeof(mat));
    for (int i = 0; i < n; i++)
      mat[i][n] = '\0';
    for (int kk = 0; kk < k; kk++)
    {
      int i, j; char c; scanf("%d %d %c", &i, &j, &c); i--, j--;
      mat[i][j] = c;
    }

    DEBUG
      for (int i = 0; i < n; i++)
        printf("\t%s\n", mat[i]);

    memset(memo, -1, sizeof(memo));
    lli ans = solve2();
    printf("%lld\n", ans);
  }
  return 0;
}
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll,ll> 
#define y1 orzkcz
using namespace std;
const int mo=998244353;
const int N=5005;
int n,m,K;
char s[N][N];
int f[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	For(i,1,K){
		int x,y; char v[10];
		scanf("%d%d%s",&x,&y,v+1);
		s[x][y]=v[1];
	}
	f[1][1]=1;
	For(i,1,n) For(j,1,m){
		int v=f[i][j];
		if (!s[i][j]){
			v=1ll*v*(mo+1)/3%mo;
			f[i+1][j]=(f[i+1][j]+2ll*v)%mo;
			f[i][j+1]=(f[i][j+1]+2ll*v)%mo;
		}
		if (s[i][j]=='R'||s[i][j]=='X')
			f[i][j+1]=(f[i][j+1]+v)%mo;
		if (s[i][j]=='D'||s[i][j]=='X')
			f[i+1][j]=(f[i+1][j]+v)%mo; 
	}
	int re=f[n][m];
	For(i,1,n*m-K) re=3ll*re%mo;
	cout<<re<<endl;
}