#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long> 
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 998244353, INF = 1e9;
int h, w, k, ans[5000][5000], cntx[5000][5000], cnty[5000][5000], po3[5001];
P p[MAX_N];
char c[MAX_N];

int main() {
    ci3(h, w, k);
    rep(i, k) {
        int x, y;
        char z;
        ci3(x, y, z);
        cntx[x - 1][y - 1]--;
        cnty[x - 1][y - 1]--;
        p[i].fi = (x - 1) * w + y - 1;
        p[i].se = i;
        c[i] = z;
    }
    rep(i, h) rep(j, w) {
        cntx[i][j]++;
        cnty[i][j]++;
    }
    po3[0] = 1;
    rep(i, 5000) po3[i + 1] = 3L * po3[i] % MOD;
    rep(i, w) rep(j, h - 1) cntx[j + 1][i] += cntx[j][i];
    rep(i, h) rep(j, w - 1) cnty[i][j + 1] += cnty[i][j];
    sort(p, p + k);
    int ind = 0;
    ans[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            if (ind < k && i == p[ind].fi / w && j == p[ind].fi % w) {
                if (c[p[ind].se] != 'D' && j < w - 1) {
                    ans[i][j + 1] =
                    (ans[i][j + 1] + scll(ans[i][j]) *
                    po3[cntx[h - 1][j] - cntx[i][j]] % MOD) % MOD;
                }
                if (c[p[ind].se] != 'R' && i < h - 1) ans[i + 1][j] = 
                    scll(ans[i][j]) * po3[cnty[i][w - 1] - cnty[i][j]] % MOD;
                ind++;
                continue;
            }
            if (j < w - 1) 
                ans[i][j + 1] = (ans[i][j + 1] + 2L * ans[i][j] *
                po3[cntx[h - 1][j] - cntx[i][j]] % MOD) % MOD;
            if (i < h - 1) ans[i + 1][j] = 2L * ans[i][j] *
                po3[cnty[i][w - 1] - cnty[i][j]] % MOD;
        }
    }
    if (k == 0 || p[k - 1].fi != h * w - 1)
        ans[h - 1][w - 1] = 3L * ans[h - 1][w - 1] % MOD;
    co(ans[h - 1][w - 1]);
    return 0;
}

// Author: wlzhouzhuan
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fir first
#define sec second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
  int x = 0, f = 0; char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
template<typename T> void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
  print(x), putchar(let);
}

const int N = 5005;
const int mod = 998244353;
const int inv3 = (mod + 1) / 3;

char a[N][N];
// 0->R, 1->D, 2->X
int dp[N][N][3];
int n, m, k;

void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int mul(int x, int y) {
  return 1ll * x * y % mod;
}
int qpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = 1ll * res * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[i][j] = '?';
    }
  }
  for (int i = 1; i <= k; i++) {
    int x = read(), y = read();
    char str[3];
    scanf("%s", str);
    a[x][y] = str[0];
  }
  if (a[1][1] == 'X') dp[1][1][2] = 1;
  else if (a[1][1] == 'R') dp[1][1][0] = 1;
  else if (a[1][1] == 'D') dp[1][1][1] = 1;
  else dp[1][1][0] = dp[1][1][1] = dp[1][1][2] = 1;
  if (a[1][1] == '?') k++;
  dp[1][1][0] = mul(dp[1][1][0], qpow(3, n * m - k));
  dp[1][1][1] = mul(dp[1][1][1], qpow(3, n * m - k));
  dp[1][1][2] = mul(dp[1][1][2], qpow(3, n * m - k));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '?') {
        if (i > 1) {
          add(dp[i][j][0], 1ll * dp[i - 1][j][1] * inv3 % mod);
          add(dp[i][j][1], 1ll * dp[i - 1][j][1] * inv3 % mod);
          add(dp[i][j][2], 1ll * dp[i - 1][j][1] * inv3 % mod);
          add(dp[i][j][0], 1ll * dp[i - 1][j][2] * inv3 % mod);
          add(dp[i][j][1], 1ll * dp[i - 1][j][2] * inv3 % mod);
          add(dp[i][j][2], 1ll * dp[i - 1][j][2] * inv3 % mod);
        }
        if (j > 1) {
          add(dp[i][j][0], 1ll * dp[i][j - 1][0] * inv3 % mod);
          add(dp[i][j][1], 1ll * dp[i][j - 1][0] * inv3 % mod);
          add(dp[i][j][2], 1ll * dp[i][j - 1][0] * inv3 % mod);
          add(dp[i][j][0], 1ll * dp[i][j - 1][2] * inv3 % mod);
          add(dp[i][j][1], 1ll * dp[i][j - 1][2] * inv3 % mod);
          add(dp[i][j][2], 1ll * dp[i][j - 1][2] * inv3 % mod);
        }
      } else {
        if (i > 1) {
          add(dp[i][j][0], dp[i - 1][j][1]);
          add(dp[i][j][1], dp[i - 1][j][1]);
          add(dp[i][j][2], dp[i - 1][j][1]);
          add(dp[i][j][0], dp[i - 1][j][2]);
          add(dp[i][j][1], dp[i - 1][j][2]);
          add(dp[i][j][2], dp[i - 1][j][2]);
        }
        if (j > 1) {
          add(dp[i][j][0], dp[i][j - 1][0]);
          add(dp[i][j][1], dp[i][j - 1][0]);
          add(dp[i][j][2], dp[i][j - 1][0]);
          add(dp[i][j][0], dp[i][j - 1][2]);
          add(dp[i][j][1], dp[i][j - 1][2]);
          add(dp[i][j][2], dp[i][j - 1][2]);
        }
      }
      if (a[i][j] == 'R') dp[i][j][1] = dp[i][j][2] = 0;
      if (a[i][j] == 'D') dp[i][j][0] = dp[i][j][2] = 0;
      if (a[i][j] == 'X') dp[i][j][0] = dp[i][j][1] = 0;
      //printf("dp[%d][%d] = %d %d %d\n", i, j, dp[i][j][0], dp[i][j][1], dp[i][j][2]);
    }
  }
  printf("%d\n", (((long long)dp[n][m][0] + dp[n][m][1]) % mod + dp[n][m][2]) % mod);
  return 0;
}