#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long long
const ll mod = 998244353;

int n, m, k;
char grd[5005][5005];
ll dp[5005][5005], pw3[10005];
int cnt[5005][5005];

int sm(int x1, int y1, int x2, int y2){
	if(x1 > x2) swap(x1, x2);
	if(y1 > y2) swap(y1, y2);
	return cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
}

ll pw(ll b, ll e){
	return pw3[e];
}

int main(){
	cin.tie(0) -> sync_with_stdio(0);

	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++)
			grd[i][j] = '?';
	for(int x, y, i = 0; i < k; i ++){
		cin >> x >> y;
		cin >> grd[x][y];
	}

	pw3[0] = 1ll;
	for(int i = 1; i <= n + m; i ++)
		pw3[i] =(pw3[i - 1] * 3ll) % mod;

	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + (grd[i][j] == '?');
	//		cout << cnt[i][j] << ' ';
		}
	//	cout << endl;
	}

	for(int i = n; i >= 1; i --){
		for(int j = m; j >= 1; j --){
			if(i == n){
				if(j == m) dp[i][j] = (grd[i][j] == '?' ? 3 : 1);
				else{
					if(grd[i][j] == '?')
						(dp[i][j] += 2 * dp[i][j + 1]) %= mod;
					else if(grd[i][j] == 'D')
						dp[i][j] = 0ll;
					else
						(dp[i][j] += dp[i][j + 1]) %= mod;
				}
			}else{
				if(j == m){
					if(grd[i][j] == '?')
						(dp[i][j] += 2 * dp[i + 1][j]) %= mod;
					else if(grd[i][j] == 'R')
						dp[i][j] = 0;
					else
						(dp[i][j] += dp[i + 1][j]) %= mod;
				}else{
					if(grd[i][j] == '?')
						(dp[i][j] += (2 * dp[i + 1][j] * pw(3ll, sm(i, j + 1, i, m))) % mod + (2 * dp[i][j + 1] * pw(3ll, sm(i + 1, j, n, j))) % mod) %= mod;
					else if(grd[i][j] == 'R')
						(dp[i][j] += (dp[i][j + 1] * pw(3ll, sm(i + 1, j, n, j))) % mod) %= mod;
					else if(grd[i][j] == 'D')
						(dp[i][j] += (dp[i + 1][j] * pw(3ll, sm(i, j + 1, i, m))) % mod) %= mod;
					else{
						(dp[i][j] += (dp[i + 1][j] * pw(3ll, sm(i, j + 1, i, m))) % mod + (dp[i][j + 1] * pw(3ll, sm(i + 1, j, n, j))) % mod) %= mod;
					}
				}
			}
		}
	}

	cout << dp[1][1] << endl;

	// for(int i = 1; i <= n; i ++){
	// 	for(int j = 1; j <= m; j ++)
	// 		cout << dp[i][j] << " ";
	// 	cout << endl;
	// }

	return 0;
}
#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>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 998244353
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int h,w;
ll dp[5555][5555];
int k;
char c[5555][5555];
ll inv;
int main()
{
	ios::sync_with_stdio(0);
	inv=quickpower(3,mod-2);
	inv%=mod; 
	cin>>h>>w>>k;
	rep(i,h+1)rep(j,w+1)c[i][j]='N';
	rep(i,k)
	{
		int x,y;
		char op;
		cin>>x>>y>>op;
		c[x][y]=op;
	}
	dp[1][1]=1;
	forn(i,1,h)
	{
		forn(j,1,w)
		{
			if(c[i-1][j]=='D'||c[i-1][j]=='X')dp[i][j]+=dp[i-1][j];
			if(c[i-1][j]=='N')dp[i][j]+=dp[i-1][j]*2*inv;
			dp[i][j]%=mod;
			if(c[i][j-1]=='R'||c[i][j-1]=='X')dp[i][j]+=dp[i][j-1];
			if(c[i][j-1]=='N')dp[i][j]+=dp[i][j-1]*2*inv;
			dp[i][j]%=mod;
		}
	}
	cout<<(dp[h][w]*quickpower(3,h*w-k))%mod<<endl;
	return 0;
}
