/* C - Robot on Grid */ 
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using pii = pair<int, int>;

const int N = 5e3 + 10;
const int mod = 998244353;
int h, w, n, s[N][N];
char a[N][N];

int ksm(int a, int b, int p)
{
    int res = 1 % p;
    while (b) {
        if (b & 1) res = (ll)res * a % p;
        a = (ll)a * a % p;
        b >>= 1;
    }
    return res;
}

int solve(void)
{
	int inv = ksm(3, mod - 2, mod);
	s[1][1] = 1;
	for (int k = 1; k <= h; ++k) {
		for (int i = 1; i <= w; ++i) {
			if ('R' == a[k][i]) 		s[k][i + 1] = (s[k][i] + s[k][i + 1]) % mod; 
			else if ('D' == a[k][i])	s[k + 1][i] = (s[k][i] + s[k + 1][i]) % mod; 
			else if ('X' == a[k][i]) {
				s[k][i + 1] = (s[k][i] + s[k][i + 1]) % mod; 
				s[k + 1][i] = (s[k][i] + s[k + 1][i]) % mod; 
			}
			else {
				int val = (ll)s[k][i] * 2 * inv % mod; 
				s[k][i + 1] = (val + s[k][i + 1]) % mod;
				s[k + 1][i] = (val + s[k + 1][i]) % mod;
			}
		}
	}
	return (ll)s[h][w] * ksm(3, h * w - n, mod) % mod;
}

signed main(int argc, char** argv)
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	#endif
	while (cin >> h >> w >> n) {
		memset(a, 0, sizeof(a));
		memset(s, 0, sizeof(s));
		for (int k = 1; k <= n; ++k) {
			int x, y;
			char c;
			cin >> x >> y >> c;
			a[x][y] = c;
		}
		cout << solve() << endl;
	}
	return 0;	
} 

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


///////modint
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};

vector<vector<mint> > dp;
int a[5000][5000];

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, k, y, x;
    cin >> h >> w >> k;
    char c;
    memset(a, 0, sizeof(a));
    mint inv3 = mint(3).inv();
    rep(i, k){
        cin >> y >> x >> c;
        y--; x--;
        if(c == 'R') a[y][x] = 1;
        else if(c == 'D') a[y][x] = 2;
        else a[y][x] = 3; 
    }
    dp.resize(h, vector<mint> (w, mint(0)));
    dp[0][0] = mint(3).pow(h * w - k);
    rep(i, h){
        rep(j, w){
            if(i < h - 1){
                if(a[i][j] == 2 || a[i][j] == 3){
                    dp[i + 1][j] += dp[i][j];
                }else if(a[i][j] == 0){
                    dp[i + 1][j] += dp[i][j] * inv3 * mint(2);
                }
            }
            if(j < w - 1){
                if(a[i][j] == 1 || a[i][j] == 3){
                    dp[i][j + 1] += dp[i][j];
                }else if(a[i][j] == 0){
                    dp[i][j + 1] += dp[i][j] * inv3 * mint(2);
                }
            }
        }
    }
    cout << dp[h - 1][w - 1].x << endl;
    return 0;
}


