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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int MOD=998244353;
char mat[5010][5010];
int dp[5010][5010],sufr[5010][5010],sufc[5010][5010];
signed main(void)
{
	IOS;
	int n,m,k; cin>>n>>m>>k;
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++)
			mat[i][j] = '0';
	}

	for(int i = 0; i < k; i++) {
		int r,c;
		char ch;
		cin>>r>>c>>ch;
		mat[r-1][c-1] = ch;
	}
	// int sufr[n][m], sufc[m][n];
	for(int i = 0; i < n; i++) {
		sufr[i][m-1] = 0;
		if(mat[i][m-1] == '0')
			sufr[i][m-1]++;
		for(int j = m-2; j >= 0; j--) {
			sufr[i][j] = sufr[i][j+1];
			if(mat[i][j] == '0')
				sufr[i][j]++;
		}
	}
	for(int i = 0; i < m; i++) {
		sufc[i][n-1] = 0;
		if(mat[n-1][i]=='0')
			sufc[i][n-1]++;
		for(int j = n-2; j >= 0; j--) {
			sufc[i][j] = sufc[i][j+1];
			if(mat[j][i] == '0')
				sufc[i][j]++;
		}
	}
	// int dp[n][m];
	// for(int i = 0; i < n; i++) {
	// 	for(int j = 0; j < m; j++)
	// 		cout<<sufr[i][j]<<" ";
	// 	cout<<endl;
	// }
	// cout<<endl<<endl;
	// for(int i = 0; i < m; i++) {
	// 	for(int j = 0; j < n; j++)
	// 		cout<<sufc[i][j]<<" ";
	// 	cout<<endl;
	// }
	// memset(dp,0,sizeof(dp));
	int po[5010];
	po[0]=1;
	for(int i = 1; i < 5010; i++) {
		po[i] = po[i-1]*3;
		if(po[i] >= MOD)
			po[i] %= MOD;
	}
	dp[0][0]=1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(i-1 >= 0) {
				if(mat[i-1][j] != 'R') {
					int tp=0;
					if(j+1<m)
						tp = sufr[i-1][j+1];
					int tmp = dp[i-1][j]*po[tp];
					if(tmp >= MOD)
						tmp %= MOD;
					if(mat[i][j] == '0') {
						tmp *= 2;
						if(tmp >= MOD)
							tmp %= MOD;
					}
					dp[i][j] += tmp;
					if(dp[i][j] >= MOD)
						dp[i][j] %= MOD;
				}
			}
			if(j-1 >= 0 && mat[i][j-1] != 'D') {
				int tp = 0;
				if(i+1 < n)
					tp = sufc[j-1][i+1];
				int tmp = dp[i][j-1]*po[tp];
				if(tmp >= MOD)
					tmp %= MOD;
				if(mat[i][j] == '0') {
					tmp *= 2;
					if(tmp >= MOD)
						tmp %= MOD;
				}
				dp[i][j] += tmp;
				if(dp[i][j] >= MOD)
					dp[i][j] %= MOD;

			}
		}
	}

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

	if(mat[n-1][m-1]=='0') {
		dp[n-1][m-1] *= 3;
		dp[n-1][m-1]%= MOD;
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}
#include <bits/stdc++.h>
#ifdef LOCAL
    #include "../../Library/DebugTool.cpp"
#endif
using namespace std;
#define ll long long
#define pii pair<int,int>
//const ll MOD = 1000000007;
const ll MOD = 998244353;
ll INF_int = 1e9+11;ll INF_ll = 1e18 + 13;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define per(i,n) for(int i = n-1;i>=0;i--)
#define mp make_pair
#define All(a) a.begin(),a.end()

void in(){}
template<typename Head,typename ...Tail>void in(Head&& head,Tail&& ...tail){cin >> head;in(std::forward<Tail>(tail)...);}
template<typename T>void vecin(vector<T> &vec){int n = vec.size();rep(i,n) cin >> vec[i];}
void out(){cout << "\n";}
template<typename Head,typename ...Tail>void out(Head&& head,Tail&& ...tail){cout << head << " ";out(std::forward<Tail>(tail)...);}
template<typename T>void vecout(vector<T> a){for(auto x:a)cout << x << " ";cout << endl;}
template<typename T>bool umax(T &x,const T &y){if(x<y){x=y;return true;}return false;}
template<typename T>bool umin(T &x,const T &y){if(x>y){x=y;return true;}return false;}

template<int MOD>
struct mint{
    ll x;

    mint(ll a=0) : x(((a%MOD)+MOD)%MOD) {}
    
    mint &operator += (const mint &a){
        x+=a.x;if(x>=MOD)x-=MOD;return *this;
    }
    mint &operator -= (const mint &a){
        x-=a.x;if(x<0)x+=MOD;return *this;
    }
    mint &operator *= (const mint &a){
        x*=a.x;x%=MOD;return *this;
    }
    mint &operator /= (const mint &a){
        x*=a.inv().x;x%=MOD;return *this;
    }

    mint operator + (const mint &a) const{
        mint res(*this);
        return res+=a;
    }
    mint operator - (const mint &a) const{
        mint res(*this);
        return res-=a;
    }
    mint operator * (const mint &a) const{
        mint res(*this);
        return res*=a;
    }
    mint operator / (const mint &a) const{
        mint res(*this);
        return res/=a;
    }

    mint pow(ll a) const{
        mint now = *this;mint ret = 1;
        while(a>0){if(a&1) ret*=now;now*=now;a/=2;}
        return ret;
    }

    mint inv() const{
        return pow(MOD-2);
    }

    mint combi(int k) const{
        k = min(x,x-k);
        mint ret = 1;
        for(int i = x;i>=x-k+1;i--) ret*=mint(i);
        for(int i = 1;i<=k;i++) ret/=mint(i);
        return ret;
    }

    friend istream& operator >> (istream& is,mint& m){
        ll a;
        is >> a;m = mint(a);
        return is;
    }

    friend ostream& operator << (ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int h,w,k;in(h,w,k);
    char state[h][w];
    rep(i,h) rep(j,w) state[i][j] = 'x';
    rep(i,k){
        int a,b;char c;in(a,b,c);
        a--;b--;state[a][b]=c;
    }
    using mint = mint<MOD>;
    ll tate_acc[w][h+1],yoko_acc[h][w+1];
    rep(i,h)rep(j,w+1) yoko_acc[i][j]=0;
    rep(i,h+1)rep(j,w) tate_acc[j][i]=0;
    rep(i,h) rep(j,w) if(state[i][j]=='x') {yoko_acc[i][j+1]=yoko_acc[i][j]+1;}else{yoko_acc[i][j+1]=yoko_acc[i][j];}
    rep(j,w) rep(i,h) if(state[i][j]=='x') {tate_acc[j][i+1]=tate_acc[j][i]+1;}else{tate_acc[j][i+1]=tate_acc[j][i];}
    mint dp[h][w];
    rep(i,h) rep(j,w) dp[i][j] = mint(0);
    dp[0][0] = 1;
    vector<mint> th(5005);
    th[0]=mint(1);
    rep(i,5005) th[i+1]=th[i]*mint(3);
    rep(i,h){
        rep(j,w){
            if(i!=0){
                if(state[i-1][j] == 'R') dp[i][j] += mint(0);
                else if(state[i-1][j] == 'D' || state[i-1][j] == 'X') dp[i][j] += (dp[i-1][j])*th[yoko_acc[i][j]];
                else  dp[i][j] += (mint(2)*dp[i-1][j])*th[yoko_acc[i][j]];                
            }
            if(j!=0){
                if(state[i][j-1] == 'D') dp[i][j] += mint(0);
                else if(state[i][j-1] == 'R' || state[i][j-1] == 'X') dp[i][j] += (dp[i][j-1])*(th[tate_acc[j][i]]);
                else  dp[i][j] += (mint(2)*dp[i][j-1])*(th[tate_acc[j][i]]);
            }
        }
    }
    if(state[h-1][w-1]=='x') dp[h-1][w-1]*=mint(3);
    out(dp[h-1][w-1]);

}