#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a; i<b; i++)
#define fr(i,a,b) for(int i=a; i>=b; i--)
typedef vector<int> vi;
typedef long long int ll;
typedef vector<ll> vll;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI 3.1415926535
// ll Mod = 1e9+7;
// ll N = 1e5;

ll Mod = 998244353;

ll mult(ll a, ll b) {
    ll ret = 1;
    ret = ((a%Mod) * (b%Mod))%Mod;
    return ret;
}

ll power(ll a, ll b = Mod-2) {
    if(b == 0) return 1;
    ll ret = 1;
    while(b) {
        if(b&1) {
            ret = mult(ret,a);
        }
        a = mult(a,a);
        b>>=1;
    }
    return ret;
}

// ll sub(ll a, ll b) {
//     ll ret = (a%Mod - b%Mod + Mod)%Mod;
//     return ret;
// }

// void seive(vector<bool> &status) {
//      for(ll i = 2; i<=1e6; i++) {
//          if(status[i]) {
//                 for(ll j =i*i; j<=1e6; j+=i) status[j] = 0;
//          }
//      }
//  }

// int getmex(vi& occr, int n, int mex) {
//     for(int i = mex; i<n; i++) {
//         if(occr[i] == 0) return i;
//     }
//     return n;
// }

// void swap(int &a, int &b) {
//     a = a + b;
//     b = a - b; 
//     a = a - b;
// }


void test_case() {
    ll h,w,k,x,y;
    cin>>h>>w>>k;
    char a,grid[h][w];
    ll moves[h+1][w+1];
    memset(moves,0,sizeof moves);

    f(i,0,h) {
        f(j,0,w) {
            grid[i][j] = '.';            
        }
    }

    f(i,0,k) {
        cin>>x>>y;
        x--; y--;
        cin>>a;
        grid[x][y] = a;
    }

    moves[0][0] = 1;
    ll d = power(3,Mod-2);
    f(i,0,h) {
        f(j,0,w) {
            if(grid[i][j] == '.') {
                int add =  mult(mult(2,moves[i][j]),d);
                moves[i+1][j] = (moves[i+1][j] + add)%Mod;
                moves[i][j+1] = (moves[i][j+1] + add)%Mod; 
            } else {
                if(grid[i][j] == 'X') {
                    moves[i][j+1] = (moves[i][j+1] + moves[i][j])%Mod;
                    moves[i+1][j] = (moves[i+1][j] + moves[i][j])%Mod;
                }
                else if(grid[i][j] == 'R') {
                    moves[i][j+1] = (moves[i][j+1] + moves[i][j])%Mod;
                }
                else {
                    moves[i+1][j] = (moves[i][j] + moves[i+1][j])%Mod;
                }
            }
        }
    }

    cout<<mult(moves[h-1][w-1],power(3,h*w-k))<<'\n';
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	fastio;
    // vector<bool> status(1e6+1,1);
    int t = 1;
    // vll primes;
    // seive(status);
    // f(i,2, 1e6+1) {
    //     if(status[i]) primes.push_back(i);
    // } 
    // cin>>t;
    while(t--) {
        test_case();
    }
}
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=5010;
const int inf=2147483647;
const int mod=998244353;
const double pi=acos(-1.0);
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int h,w,k,a[Maxn][Maxn],f[Maxn][Maxn],pw[Maxn];
int b[Maxn][Maxn],c[Maxn][Maxn];
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int main()
{
	memset(a,-1,sizeof(a));
	pw[0]=1;for(int i=1;i<=5000;i++)pw[i]=(LL)pw[i-1]*3%mod; 
	h=read(),w=read(),k=read();
	for(int i=1;i<=k;i++)
	{
		int x=read(),y=read();char o[5];
		scanf("%s",o);
		if(o[0]=='R')a[x][y]=0;
		if(o[0]=='D')a[x][y]=1;
		if(o[0]=='X')a[x][y]=2;
	}
	for(int i=1;i<=h;i++)
	for(int j=1;j<=w;j++)
	b[i][j]=b[i][j-1]+(a[i][j]==-1);
	for(int j=1;j<=w;j++)
	for(int i=1;i<=h;i++)
	c[i][j]=c[i-1][j]+(a[i][j]==-1);
	/*for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		printf("%d ",b[i][j]);puts(""); 
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		printf("%d ",c[i][j]);puts(""); 
	}*/
	f[1][1]=1;
	for(int i=1;i<=h;i++)
	for(int j=1;j<=w;j++)
	if(i!=1||j!=1)
	{
		f[i][j]=0;
		if(i>1&&a[i-1][j]!=0)
		{
			if(a[i-1][j]==-1)upd(f[i][j],(LL)f[i-1][j]*2%mod*pw[b[i][j-1]]%mod);
			else upd(f[i][j],(LL)f[i-1][j]*pw[b[i][j-1]]%mod);
		}
		if(j>1&&a[i][j-1]!=1)
		{
			if(a[i][j-1]==-1)upd(f[i][j],(LL)f[i][j-1]*2%mod*pw[c[i-1][j]]%mod);
			else upd(f[i][j],(LL)f[i][j-1]*pw[c[i-1][j]]%mod);
		}
//		printf("%d %d %d %d %d\n",i,j,b[i][j],c[i][j],f[i][j]);
	}
	if(a[h][w]==-1)f[h][w]=(LL)f[h][w]*3%mod;
	printf("%d",f[h][w]);
}