#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <functional>
#include <cassert>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}
template <class T> ostream& operator<<(ostream& s, const vector<T>& a) { for(auto i : a) s << i << ' '; return s; }

constexpr ll INFL = 1LL << 60;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    static const long long mod = 998244353;
    long long x;
    mint(long long 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;}

    friend const mint operator+(const mint& a, const mint& b) { mint ret = a; return ret += b; }
    friend const mint operator-(const mint& a, const mint& b) { mint ret = a; return ret -= b; }
    friend const mint operator*(const mint& a, const mint& b) { mint ret = a; return ret *= b; }
    friend ostream& operator<<(ostream& s, const mint& a) { return s << a.x; }

    mint pow(long long 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();}
    friend const mint operator/(const mint& a, const mint& b) { mint ret = a; return ret /= b; }
};

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h, string(w, '.'));
    rep(i, k) {
        ll h_, w_;
        char c_;
        cin >> h_ >> w_ >> c_;
        s[h_-1][w_-1] = c_;
    }
    /*
    rep(i, h) {
        rep(j, w) cout << s[i][j] << ' ';
        cout << endl;
    }
    */
    using vm = vector<mint>;
    vector<vm> dp(h, vm(w));
    dp[0][0] = mint(3).pow(h*w-k);
    mint inv3 = mint(3).inv();
    rep(i, h) rep(j, w) {
        if(i > 0) {
            if(s[i-1][j] == '.') dp[i][j] += dp[i-1][j] * 2 * inv3;
            else if(s[i-1][j] == 'D' || s[i-1][j] == 'X') dp[i][j] += dp[i-1][j];
        }
        if(j > 0) {
            if(s[i][j-1] == '.') dp[i][j] += dp[i][j-1] * 2 * inv3;
            else if(s[i][j-1] == 'R' || s[i][j-1] == 'X') dp[i][j] += dp[i][j-1];
        }
    }
    cout << dp[h-1][w-1] << endl;
    /*
    rep(i, h) {
        rep(j, w) cout << dp[i][j] << ' ';
        cout << endl;
    }
    */
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}
#include<bits/stdc++.h>
using namespace::std;

const int N = 5000 + 10;
const int MOD = 998244353;
const int F = (2LL * 332748118) % MOD;

int n;
int m;
int k;
int fact;
char v[N][N];
int memo[N][N];

int add(int a, int b){
	return (a + b) % MOD;
}

int mul(int a, int b){
	return (1LL * a * b) % MOD;
}

int pow_mod(int a, int b){
	int r = 1;
	while(b > 0){
		if(b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int solve(){
	memo[1][1] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(i + j == n + m) continue;
			if(!isalpha(v[i][j])) memo[i][j] = mul(memo[i][j], F);
			if(isalpha(v[i][j])){
				if(v[i][j] == 'R'){
					memo[i][j + 1] = add(memo[i][j + 1], memo[i][j]);
				}
				else if(v[i][j] == 'D'){
					
					memo[i + 1][j] = add(memo[i + 1][j], memo[i][j]);
				}
				else{
					memo[i + 1][j] = add(memo[i + 1][j], memo[i][j]);
					memo[i][j + 1] = add(memo[i][j + 1], memo[i][j]);
				}
			}
			else{
				memo[i + 1][j] = add(memo[i + 1][j], memo[i][j]);
				memo[i][j + 1] = add(memo[i][j + 1], memo[i][j]);
			}
		}
	}
	return mul(memo[n][m], pow_mod(3, n * m - k));
}

int main(){
	scanf("%d %d %d", &n, &m, &k);
	memset(v, ' ', sizeof v);
	for(int i = 0; i < k; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		char c = getchar();
		while(!isalpha(c)) c = getchar();
		v[x][y] = c;
	}
	printf("%d\n", solve());
	return 0;
}
