#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 998244353
#define INF LONG_MAX/3
#define bit(n) (1LL<<(n))

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; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

char ban[5005][5005];
ll dp[5005][5005];

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	ll H, W, K;
	cin >> H >> W >> K;
	rep(y, H) rep(x, W) ban[y][x] = '.';

	rep(i, K) {
		ll h, w;
		char c;
		cin >> h >> w >> c;
		h--;w--;
		ban[h][w] = c;
	}
	dp[0][0] = modpow(3, H * W - K);

	ll memo = modpow(3, DIV-2);
	rep(h, H) rep(w, W) {
		if(ban[h][w] == 'R') {
			dp[h][w+1] += dp[h][w];
			dp[h][w+1] %= DIV;
		} else if(ban[h][w] == 'D') {
			dp[h+1][w] += dp[h][w];
			dp[h+1][w] %= DIV;
		} else if(ban[h][w] == 'X') {
			dp[h][w+1] += dp[h][w];
			dp[h][w+1] %= DIV;

			dp[h+1][w] += dp[h][w];
			dp[h+1][w] %= DIV;
		} else {
			//R
			dp[h][w+1] += dp[h][w] * memo;
			dp[h][w+1] %= DIV;
			//D
			dp[h+1][w] += dp[h][w] * memo;
			dp[h+1][w] %= DIV;

			//X
			dp[h][w+1] += dp[h][w] * memo;
			dp[h][w+1] %= DIV;

			dp[h+1][w] += dp[h][w] * memo;
			dp[h+1][w] %= DIV;
		}
	}
	cout << dp[H-1][W-1] << endl;
}


#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define priority_queue std::priority_queue
#define F first
#define S second

ll MOD=998244353;
int h, w, k;
char g[5005][5005];
ll dp[5005][5005], emp[5005][5005], po3[200005], inv;

ll modpow(ll x, ll e){
	if(x==0) return 0;
	if(e==0) return 1;
	ll y=modpow(x, e/2);
	if(e%2==0) return (y*y)%MOD;
	return ((y*y)%MOD*x)%MOD;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w>>k;
	po3[0]=1;
	for(int i=1;i<200005;i++){
		po3[i]=(po3[i-1]*3)%MOD;
	}
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			g[i][j]='.';
		}
	}
	for(int i=0;i<k;i++){
		int x, y;
		char c;
		cin>>x>>y>>c;
		g[x][y]=c;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			emp[i][j]=emp[i-1][j]+emp[i][j-1]-emp[i-1][j-1]+(g[i][j]=='.');
		}
	}
	if(g[1][1]=='.') dp[1][1]=3;
	else dp[1][1]=1;
	inv=modpow(3, MOD-2);
	for(int x=1;x<=h;x++){
		for(int y=1;y<=w;y++){
			if(x+y==2) continue;
			ll c=po3[emp[x][y]-emp[x][y-1]], r=po3[emp[x][y]-emp[x-1][y]];
			if(g[x][y-1]=='R' || g[x][y-1]=='X'){
				dp[x][y]=(dp[x][y]+dp[x][y-1]*c)%MOD;
			}
			if(g[x-1][y]=='D' || g[x-1][y]=='X'){
				dp[x][y]=(dp[x][y]+dp[x-1][y]*r)%MOD;
			}
			if(g[x][y-1]=='.'){
				dp[x][y]+=(((2*inv*dp[x][y-1])%MOD)*c)%MOD;
				dp[x][y]%=MOD;
			}
			if(g[x-1][y]=='.'){
				dp[x][y]+=(((2*inv*dp[x-1][y])%MOD)*r)%MOD;
				dp[x][y]%=MOD;
			}
		}
	}
	cout<<dp[h][w]<<endl;
}