#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
constexpr int MOD = 998244353;
constexpr int prob = 665496236;
long long dp[5001];

int pow(long long x, int n){
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= MOD;
        x *= x, x %= MOD;
        n >>= 1; 
    }
    return ret;
}

int main(){
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);

    vector<vector<pair<int, char>>> X(H);
    for(int i = 0; i < H; ++i) X[i].reserve(W);

    for(int i = 0; i < K; ++i){
        int x, y;
        char c;
        scanf("%d%d%c%c", &x, &y, &c, &c);
        --x, --y;
        X[x].emplace_back(y, c);
    }

    dp[0] = 1;
    for(int i = 0; i < H; ++i){
        sort(X[i].begin(), X[i].end());
        auto itr = X[i].begin();

        for (int j = 0; j < W; ++j){
            dp[j] %= MOD;
            if(itr != X[i].end() and itr->first == j){
                char c = itr->second;
                if(c != 'D') dp[j + 1] += dp[j];
                if((i != H - 1) & c == 'R') dp[j] = 0;
                ++itr;
            }
            else{
                dp[j + 1] += dp[j] * prob;
                if(i != H - 1) dp[j] *= prob;
            }
        }
    }

    long long ans = dp[W - 1];
    ans *= pow(3, H * W - K);
    printf("%d", ans % MOD);

    return 0;
}


#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define foreach(itr, c) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

typedef long long LL;
typedef pair <int, int> pii;
typedef vector <int> vi;

const int N = 5005;
const LL P = 998244353;

int n, m, K;
int a[N][N];
LL f[N][N];
bool vis[N][N];

LL mul1, mul2, mul3;

LL _pow(LL x, LL y){
    if (y < 0) return 0;
    LL ret = 1;
    for (; y; y >>= 1, x = x * x % P)
        if (y & 1) ret = ret * x % P;
    return ret;
}

LL dp(int r, int c){
    if (r == 1 && c == 1) return 1;
    if (vis[r][c]) return f[r][c];
    vis[r][c] = 1;
    LL& ret = f[r][c];

    if (r > 1 && a[r - 1][c] != 1){
        if (!a[r - 1][c]) ret += mul3 * dp(r - 1, c);
        else ret += dp(r - 1, c);
        ret %= P;
    }
    if (c > 1 && a[r][c - 1] != 2){
        if (!a[r][c - 1]) ret += mul3 * dp(r, c - 1);
        else ret += dp(r, c - 1);
        ret %= P;
    }

    return ret;
}

int main(){
    scanf("%d%d%d", &n, &m, &K);
    mul3 = _pow(3, P - 2);
    mul3 = mul3 * 2 % P;
    rep(i, K){
        int x, y; char c;
        scanf("%d%d %c", &x, &y, &c);
        if (c == 'R') a[x][y] = 1;
        if (c == 'D') a[x][y] = 2;
        if (c == 'X') a[x][y] = 3;
    }
    
    LL ret = dp(n, m);
    ret = ret * _pow(3, n * m - K) % P;
    printf("%lld\n", ret);
    return 0;
}