#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=998244353;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n,m,k;cin>>n>>m>>k;
    vector<vector<char>>grid(n,vector<char>(m,'.'));
    for (int i = 0; i < k; ++i)
    {
    	int h,w;char c;cin>>h>>w>>c;
    	h--;
    	w--;
    	grid[h][w]=c;
    }

    vv row(n+1,v(m+1,0)),col(n+1,v(m+1,0));
    for(int i=n-1;i>=0;i--)
    {
    	for(int j=m-1;j>=0;j--)
    	{
    		row[i][j]=row[i][j+1];
    		col[i][j]=col[i+1][j];
    		if(grid[i][j]=='.')
    		{
    			row[i][j]++;
    			col[i][j]++;
    		}
    	}
    }
    v powers(n+m+2,1);
    for(int i=1;i<=n+m+1;i++)
    	powers[i]=MOD(powers[i-1]*3);
    vv dp(n+1,v(m+1,0));
    dp[n-1][m-1]=1;
    if(grid[n-1][m-1]=='.')
    	dp[n-1][m-1]=3;
   	for(int i=n-1;i>=0;i--)
   	{
   		for(int j=m-1;j>=0;j--)
   		{
   			if(i==(n-1) && j==(m-1))
   				continue;
   			if(grid[i][j]=='R')
   			{
   				dp[i][j]=MOD(dp[i][j+1]*powers[col[i+1][j]]);
   			}
   			else if(grid[i][j]=='D')
   			{
   				dp[i][j]=MOD(dp[i+1][j]*powers[row[i][j+1]]);
   			}
   			else if(grid[i][j]=='X')
   			{
   				dp[i][j]=MOD(MOD(dp[i][j+1]*powers[col[i+1][j]])+MOD(dp[i+1][j]*powers[row[i][j+1]]));
   			}
   			else
   			{
   				dp[i][j]=MOD(2*MOD(dp[i][j+1]*powers[col[i+1][j]])+2*MOD(dp[i+1][j]*powers[row[i][j+1]]));
   			}
   		}
   	}
   	cout<<dp[0][0]<<endl;

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 998244353;
const long long INF = 9999999999999999;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


long long pow(long long x, long long n, long long MM) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MM;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MM;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}


int main(){
  ll H,W,K;
  cin>>H>>W>>K;
  char ban[H+2][W+2] = {};
  ll masu = 0;
  rep(i,H+1){
    rep(k,W+1){
      ban[i][k] = '.';
      masu++;
    }
  }
  ll kakeru = pow(3,(H*W-K),MOD);
  
  ll ans[H+2][W+2];
  rep(i,K){
    ll a,b;
    char c;
    cin>>a>>b>>c;
    ban[a][b] = c;
  }

  rep(i,H+1){
    rep(k,W+1){
      ans[i][k] = 0;
    }
  }
  ll waru = pow(3,(MOD-2),MOD);
  ans[1][1] = kakeru;
  for(ll i = 1;i<=H;i++){
    for(ll k = 1;k<=W;k++){
      if(ban[i][k] == 'D'){
        ans[i+1][k] += ans[i][k];
        ans[i+1][k]%=MOD;
      }
      if(ban[i][k] == 'R'){
        ans[i][k+1] += ans[i][k];
        ans[i][k+1]%=MOD;
      }
      if(ban[i][k] == 'X'){
        ans[i+1][k] += ans[i][k];
        ans[i][k+1] += ans[i][k];
        ans[i+1][k]%=MOD;
        ans[i][k+1]%=MOD;
      }
      if(ban[i][k] == '.'){
        ans[i+1][k] += ans[i][k]*2%MOD*waru%MOD;
        ans[i][k+1] += ans[i][k]*2%MOD*waru%MOD;
      }
    }
  }
  cout << ans[H][W]%MOD << endl;
  return 0;
}