#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false

//累乗(繰り返し二乗法)
long long power(long long b,long long e){
  long long r=1;
  while(e){
      if(e&1){
          r=(r*b)%MOD;
      }
      b=(b*b)%MOD;
      e >>=1;
  }
  return r;
}





int main(void){
    ll H,W,K;
    vector<pair<pair<ll,ll>,char>> HWC;
    
    cin >> H >> W >> K;
    REP(i,K){
        ll h,w;
        char c;
        cin >> h >> w >> c;
        h--;w--;
        HWC.push_back({{h,w},c});
    }
    
    const ll MEM = 5100;
    ll S[MEM][MEM]={};
    REP(i,HWC.size()){
        if(HWC[i].second=='D')S[HWC[i].first.first][HWC[i].first.second]=1;
        if(HWC[i].second=='R')S[HWC[i].first.first][HWC[i].first.second]=2;
        if(HWC[i].second=='X')S[HWC[i].first.first][HWC[i].first.second]=3;
    }
    
    ll inv3 = power(3,MOD-2);
    ll tinv3 = 2*inv3;
    ll dp[MEM][MEM]={};
    dp[0][0]=1;
    
    REP(i,H){
        REP(j,W){
            
            ll d=0,r=0;
            if(i!=0 && S[i-1][j]!=2){
                d=dp[i-1][j];
            }
            if(i!=0 && S[i-1][j]==0){
                d=(d*tinv3)%MOD;
            }
            
            
            if(j!=0 && S[i][j-1]!=1){
                r=dp[i][j-1];
            }
            if(j!=0 && S[i][j-1]==0){
                r=(r*tinv3)%MOD;
            }
            
            dp[i][j]+=d+r;
            dp[i][j]%=MOD;
            
            
        }
        
        //REP(j,W){cout << (dp[i][j]*power(3,H*W-K))%MOD << " ";}cout << endl;
    }
    
    cout << (dp[H-1][W-1]*power(3,H*W-K))%MOD << endl;
    
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
#define maxn 3e5+50

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}

const ll mod = 998244353;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int h,w;cin >> h >> w;
    vector<vector<char>>s(h,vector<char>(w,'?'));
    ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    int k;cin >> k;
    for(int i = 0;i<k;i++){
        int x,y;cin >> x >> y;
        char c;cin >> c;
        x--;y--;
        s[x][y] = c;
    }
    dp[0][0] = 1;
    ll inv3 = modpow(3,mod-2,mod);
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            char c = s[i][j];
            if(c=='R'||c=='X') dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
            if(c=='D'||c=='X') dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
            if(c=='?'){
                dp[i][j+1] = (dp[i][j+1]+dp[i][j]*2*inv3%mod)%mod;
                dp[i+1][j] = (dp[i+1][j]+dp[i][j]*2*inv3%mod)%mod;
            }
        }
    }
    cout << dp[h-1][w-1]*modpow(3,h*w-k,mod)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}
