//wtrl,everybody hangbeat me
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,int> mpci;
typedef map<int,int> mpii;
typedef map<string,int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))
#define INF 1e9
#define PI acos(-1)

/*=====================================================================*/

string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
string turn(int n,int k)
{
	string s="";
	while(n)
	{
		s+=(char)(n%k+'0');
		n/=k;
	}
	reverse(s.begin(),s.end());
	return s;
}
const string turn16(int n)
{
	string s="";
	while(n!=0)
	{
		if(n%16>9)
		  s+=(char)('A'+n%16-10);
		else
		  s+=(char)('0'+n%16);
		n/=16;
	}
	reverse(s.begin(),s.end());
	return s;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
ll h,w,k,ans,inv=1,dp[5010][5010],mod=998244353;
char a[5010][5010];
/*======================================================================*/
int main()
{
    std::ios::sync_with_stdio(false);
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
    cin>>h>>w>>k;
	int r,c;
	char x;
	rep(i,k)
	{
		cin>>r>>c>>x;
		a[--r][--c]=x;
	}
	while(inv%3) 
	{
	 inv+=mod;
    }
	inv/=3;
	dp[0][0]=1;
	rep(i,h)
	{ 
	  rep(j,w)
	  {
		if(a[i][j]!='R'&&i+1<h) 
		{
			dp[i+1][j]+=dp[i][j]*(a[i][j]==0?2*inv:1);
			dp[i+1][j]%=mod;
		}
		if(a[i][j]!='D'&&j+1<w) 
		{
			dp[i][j+1]+=dp[i][j]*(a[i][j]==0?2*inv:1);
			dp[i][j+1]%=mod;
		}
	  }
    }
	ans=dp[h-1][w-1];
	rep(i,h*w-k)
	{ 
	  ans=ans*3%mod;
    }
	cout<<ans<<endl;
  return 0;
}



#include<bits/stdc++.h>
#define ll long long 
#define ld long double 
#define MOD 998244353
#define f first 
#define s second 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const ll inf=1e18+5;
const int maxN=1e6+1;
ll power(ll a,int n){
    if(n==0){
        return 1ll;
    }
    if(n==1){
        return a%MOD;
    }
    ll p=power(a,n/2);
    p=(p*p)%MOD;
    if(n%2==1){
        p=(p*a)%MOD;
    }
    return p;
}
int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int h,w,k;
    cin>>h>>w>>k;
    int u,v,c;
    char ch;
    vector<vector<int>> a(h,vector<int>(w,0));
    for(int i=0;i<k;i++){
        cin>>u>>v>>ch;
        u--;
        v--;
        if(ch=='R'){
            c=1;
        }
        else if(ch=='D'){
            c=2;
        }
        else{
            c=3;
        }
        a[u][v]=c;
    }
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    ll inv3=power(3ll,MOD-2);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0){
                dp[i][j]=power(3ll,h*w-k);
            }
            if(i>0){
                if(a[i-1][j]==0){
                    dp[i][j]=(dp[i][j]+((dp[i-1][j]*inv3)%MOD)*2)%MOD;
                }
                else if(a[i-1][j]==2 || a[i-1][j]==3){
                    dp[i][j]=(dp[i][j]+(dp[i-1][j])%MOD)%MOD;
                }
            }
            if(j>0){
                if(a[i][j-1]==0){
                    dp[i][j]=(dp[i][j]+((dp[i][j-1]*inv3)%MOD)*2)%MOD;
                }
                else if(a[i][j-1]==1 || a[i][j-1]==3){
                    dp[i][j]=(dp[i][j]+(dp[i][j-1])%MOD)%MOD;
                }
            }
        }
    }
    cout<<(dp[h-1][w-1]+MOD)%MOD<<endl;
}