#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define N 300100
#define MOD 998244353
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rep3(i, a, b) for(int i = a; i >= b; --i)
#define eb emplace_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
struct Setup_io {
	Setup_io() {
		ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
		cout << fixed << setprecision(15);
	}
} setup_io;
int mp[5010];


int main() {
	ll dp[10000];
	ll dp2[10000];
	vector<pair<pii, int> >pp;
    int x, y;
	int n, m, k;
	ll z, s;
	ll lq[N];
	ll rq;
	rep(i, N)lq[i] = 1;
	char c[3];
	cin >> n >> m >> k;
	rep(i, k) {
		rep(j, 3)c[j] = 0;
		cin >> x >> y;
		cin >> c;
		if (c[0] == 'R')pp.pb({ {x - 1,y - 1},1 });
		if (c[0] == 'D')pp.pb({ {x - 1,y - 1},2 });
		if (c[0] == 'X')pp.pb({ {x - 1,y - 1},3 });
	}
	int idx = 0;
	sort(all(pp), greater<pair<pii, int> >());
	z = 1;
	rep(j, m)mp[j] = 0;
	while (idx < k) {
		if (pp[idx].first.first < n - 1)break;
		else mp[pp[idx].first.second] = pp[idx].second;
		idx++;
	}
	rep3(j, m - 1, 0) {
		if (j == m - 1) {
			if (mp[j] == 0) {
				z = (z * 3) % MOD;
				lq[j] = (lq[j] * 3) % MOD;
			}
		}
		else {
			if (mp[j] == 2)z = 0;
			if (mp[j] == 0) {
				z = (z * 2) % MOD;
				lq[j] = (lq[j] * 3) % MOD;
			}
		}
		dp[j] = z;
	}
	rep(j, m)dp2[j] = dp[j];
	rep3(i, n - 2, 0) {
		rq = 1;
		rep(j, m)mp[j] = 0;
		while (idx < k) {
			if (pp[idx].first.first < i)break;
			else mp[pp[idx].first.second] = pp[idx].second;
			idx++;
		}
		rep3(j, m - 1, 0) {
			if (j == m - 1) {
				if (mp[j] == 0) {
					dp[j] = (dp2[j] * 2) % MOD;
					rq = (rq * 3) % MOD;
					lq[j] = (lq[j] * 3) % MOD;
				}
				if (mp[j] == 1)dp[j] = 0;
				if (mp[j] == 2)dp[j] = dp2[j];
				if (mp[j] == 3)dp[j] = dp2[j];
			}
			else {
				if (mp[j] == 0) {
					dp[j] = (lq[j] * dp[j + 1]) % MOD;;
					z = (rq*dp2[j]) % MOD;
					dp[j] = ((dp[j] + z) * 2) % MOD;
					rq = (rq * 3) % MOD;
					lq[j] = (lq[j] * 3) % MOD;
				}
				if (mp[j] == 1)dp[j] = (lq[j] * dp[j + 1]) % MOD;
				if (mp[j] == 2)dp[j] = (rq*dp2[j]) % MOD;
				if (mp[j] == 3) {
					dp[j] = (lq[j] * dp[j + 1]) % MOD;;
					z = (rq*dp2[j]) % MOD;
					dp[j] = (dp[j] + z) % MOD;
				}
			}
		}
		rep(j, m) dp2[j] = dp[j];
	}
	cout << dp2[0] << endl;
	return 0;
}

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

const int mod = 998244353;
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;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


char a[5005][5005];
mint dp[5005][5005];

int main(){
  int h, w, k; cin >> h >> w >> k;
  
  for(int i = 0; i < k; i++){
    int A, B; char ch;
    cin >> A >> B >> ch;
    A--; B--;
    a[A][B] = ch;
  }
  
  dp[0][0] = 1;
  mint t = mint(3).inv();
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j]=='R') dp[i][j+1] += dp[i][j];
      if(a[i][j]=='D') dp[i+1][j] += dp[i][j];
      if(a[i][j]=='X'){
        dp[i][j+1] += dp[i][j];
        dp[i+1][j] += dp[i][j];
      }
      if(a[i][j]=='\0'){
        dp[i][j+1] += dp[i][j]*mint(2)*t;
        dp[i+1][j] += dp[i][j]*mint(2)*t;
      }
    }
  }
  mint ans = dp[h-1][w-1];
  ans *= mint(3).pow(h*w-k);
  cout << ans << endl;
  return 0;
}