#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define STRING(str) #str
#define ll long long
#define ld long double

template <typename T>
void print(T x, string name) {
	cout << name+": " << x << endl;
}

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

template <typename T >
void print_vec_2d(vector<vector<T>> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << "[ ";
		for (int j=0;j<x[i].size();j++) {
			cout << x[i][j];
			if (j != x[i].size()-1) cout << ", ";
			else {
				cout << " ]";
				if (!((i == x.size()-1) && (j == x[i].size()-1))) {
					cout << "," << endl;
				}
			}
		}
	}
	cout << " ]" << endl;
}

template <typename T >
void print_vec_3d(vector<vector<vector<T>>> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << "[ ";
		for (int j=0;j<x[i].size();j++) {
			cout << "[ ";
			for (int k=0;k<x[i][j].size();k++) {
				cout << x[i][j][k];
				if (k != x[i][j].size()-1) cout << ", ";
				else {
					cout << " ]";
					if (!((i == x.size()-1) && (j == x[i].size()-1) && (k == x[i][j].size()-1))) {
						cout << "," << endl;
					}
				}
			}
			if (j != x[i].size()-1) cout << ", ";
			else {
				cout << " ]";
				if (!((i == x.size()-1) && (j == x[i].size()-1))) {
					cout << "," << endl;
				}
			}
		}
	}
	cout << " ]" << endl;
}


ll mod = 998244353;

long long modpow(long long a, long long x) {
    long long tmp = x;
    long long val = a;
    long long ret = 1LL;
    while (tmp>0) {
        if (tmp%2 == 1) ret = ret*val%mod;
        val = val*val%mod;
        tmp /= 2;
    }
    return ret;
}


long long modinv(long long a) {
    return modpow(a, mod-2);
}

ll H, W, K;
vector<int> h, w;
vector<char> c;


vector<vector<ll>> dp;
map<pair<int, int>, char> char_mp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> H >> W >> K;

	dp = vector<vector<ll>>(H, vector<ll>(W, 0LL));
	// dp[0][0] = 1LL;
	dp[0][0] = modpow(3LL, H*W-K);
	h = vector<int>(K);
	w = vector<int>(K);
	c = vector<char>(K);
	for (int i=0;i<K;i++) {
		cin >> h[i] >> w[i] >> c[i];
		h[i]--;w[i]--;
		char_mp[make_pair(h[i], w[i])] = c[i];
	}

	ll modinv_3_2 = modinv(3)*2%mod;
	// 配るdp
	for (int i=0;i<H;i++) {
		for (int j=0;j<W;j++) {
			pair<int, int> p = make_pair(i, j);
			if (char_mp.count(p)) {
				char tmp = char_mp[p];
				if (tmp == 'R') {
					if (j+1 < W) {
						dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
					}
				} else if (tmp == 'D') {
					if (i+1 < H) {
						dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
					}
				} else { // tmp == 'X'
					if (j+1 < W) {
						dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
					}
					if (i+1 < H) {
						dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
					}
				}
			} else {
				if (j+1 < W) {
					dp[i][j+1] = (dp[i][j+1]+dp[i][j]*modinv_3_2)%mod;
				}
				if (i+1 < H) {
					dp[i+1][j] = (dp[i+1][j]+dp[i][j]*modinv_3_2)%mod;
				}
				// if (j+1 < W) {
					// dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
				// }
				// if (i+1 < H) {
					// dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
				// }
			}
		}
	}

	// print_vec_2d(dp, STRING(dp));

	cout << dp[H-1][W-1] << "\n";
}
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
const int mod=998244353;
const int mex=5002;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)
#define int long long
int dp[mex][mex];
char a[mex][mex];
int power(int a,int b)
{
    int ans=1,f=a;
    while(b)
    {
        if(b&1) ans=(ans*f)%mod;
        f=(f*f)%mod;
        b=b>>1;
    }
    return ans;
}
signed main()
{
    int h,w,k;
    cin>>h>>w>>k;
    fo(i,1,h+1)
    fo(j,1,w+1)
    a[i][j]=0;

    fo(i,0,k)
    {
        int a1,b;
        char c;
        cin>>a1>>b>>c;
        a[a1][b]=c;
    }
    dp[1][1]=1;
    int fr1[h+1]={0},fr2[w+1]={0};
    fo(i,1,h+1)
    fo(j,1,w+1)
    {
        int cn1=0,cn2=0;
        if(i>1)
        {
            if(a[i-1][j]=='D'||a[i-1][j]=='X') dp[i][j]=(dp[i][j]+(power(3,fr1[i])*dp[i-1][j])%mod)%mod;
            else if(a[i-1][j]==0) dp[i][j]=(dp[i][j]+((2*power(3,fr1[i]))%mod*dp[i-1][j])%mod)%mod; 
            if(a[i-1][j]==0) cn1++;
        }
        if(j>1)
        {
            if(a[i][j-1]=='R'||a[i][j-1]=='X') dp[i][j]=(dp[i][j]+(power(3,fr2[j])*dp[i][j-1])%mod)%mod;
            else if(a[i][j-1]==0) dp[i][j]=(dp[i][j]+((2*power(3,fr2[j]))%mod*dp[i][j-1])%mod)%mod; 
            if(a[i][j-1]==0) cn2++;
        }
        // if(cn1&&cn2) dp[i][j]=(dp[i][j]*6)%mod;
        // else if(cn1||cn2)
        // {  dp[i][j]=(dp[i][j]*2)%mod;
        // if(cn1==0&&i>1&&a[i-1][j]=='D') dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        // if(cn2==0&&j>1&&a[i][j-1]=='R') dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        // }
        if(a[i][j]==0) {fr1[i]++;fr2[j]++;}
    }
//     fo(i,1,h+1)
//  {   fo(j,1,w+1)
//     {
//         cout<<dp[i][j]<<" ";
//     }
//     cout<<endl;
// }
   if(a[h][w]==0) dp[h][w]=(dp[h][w]*3)%mod;
    cout<<dp[h][w]%mod<<endl;

}
