#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;

const ll MAX_N = 5;

// a^n (mod.MOD)を求める。計算量はO(logn)
ll modpow(ll a, ll n, ll MOD = mod) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1, MOD))%MOD;
    }
    return (modpow(a, n/2, MOD) * modpow(a, n/2, MOD))%MOD;
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod

void init() {
    inv[0] = inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll h, w, k;
    cin >> h >> w >> k;

    vvl board(h, vl(w, -1));
    rep(i, k) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        x--;  y--;
        if(c == 'R') {  
            board[x][y] = 0;
        }
        else if(c == 'D') {
            board[x][y] = 1;
        }
        else if(c == 'X') {
            board[x][y] = 2;
        }
    }

    init();

    vvl dp(h, vl(w));  // dp[i][j] : (i, j)への移動経路数の総和
    dp[0][0] = modpow(3LL, h*w - k);
    exrep(j, 1, w-1) {
        if(board[0][j-1] == -1) {
            dp[0][j] = 2*inv[3]*dp[0][j-1]%mod;
        }
        else if(board[0][j-1] == 1) {
            dp[0][j] = 0;
        }
        else {
            dp[0][j] = dp[0][j-1];
        }
    }
    exrep(i, 1, h-1) {
        if(board[i-1][0] == -1) {
            dp[i][0] = 2*inv[3]*dp[i-1][0]%mod;
        }
        else if(board[i-1][0] == 0) {
            dp[i][0] = 0;
        }
        else {
            dp[i][0] = dp[i-1][0];
        }
    }

    exrep(i, 1, h-1) {
        exrep(j, 1, w-1) {
            if(board[i-1][j] == -1) {
                dp[i][j] += 2*inv[3]*dp[i-1][j];
            }
            else if(board[i-1][j] == 1 || board[i-1][j] == 2) {
                dp[i][j] += dp[i-1][j];
            }
            if(board[i][j-1] == -1) {
                dp[i][j] += 2*inv[3]*dp[i][j-1];
            }
            else if(board[i][j-1] == 0 || board[i][j-1] == 2) {
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= mod;
        }
    }

    out(dp[h-1][w-1]);
    re0;
}
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 0x7f7f7f7f
#define LL_INF 0x7f7f7f7f7f7f7f7f
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 998244353

vector<ll> three(5000*5000+1);
void solve() {
    int n, m, k; cin >> n >> m >> k;
    vector<vector<int>> r(n+1, vector<int>(m+1));
    vector<vector<int>> d(n+1, vector<int>(m+1));
    vector<vector<int>> x(n+1, vector<int>(m+1));
    vector<vector<int>> a(n+1, vector<int>(m+1));
    vector<vector<int>> num(n+1, vector<int>(m+1));
    for(int i=1;i<=n*m;i++) three[i] = (three[i-1] * 3) % MOD;
    for(int i=0;i<k;i++) {
        int x, y;
        char c;
        cin >> x >> y;
        cin >> c;
        if(c == 'R') {
            a[x][y] = 1;
        }
        else if(c == 'D') {
            a[x][y] = 2;
        }
        else if(c == 'X') {
            a[x][y] = 3;
        }
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            num[i][j] = num[i-1][j] + num[i][j-1] - num[i-1][j-1] + (a[i][j] == 0);
        }
    }

    if(a[1][1] == 0) {
        r[1][1] = d[1][1] = x[1][1] = 1;
    } else if(a[1][1] == 1) {
        r[1][1] = 1;
    } else if(a[1][1] == 2) {
        d[1][1] = 1;
    } else if(a[1][1] == 3) {
        x[1][1] = 1;
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(i == 1 && j == 1) continue;
            r[i][j] = (((r[i][j-1] + x[i][j-1]) % MOD) * three[num[i][j] - num[i][j - 1] - (a[i][j] == 0)]) % MOD;
            r[i][j] += (((d[i-1][j] + x[i-1][j]) % MOD) * three[num[i][j] - num[i - 1][j] - (a[i][j] == 0)]) % MOD;
            r[i][j] %= MOD;

            x[i][j] = d[i][j] = r[i][j];

            if(a[i][j] == 1) {
                d[i][j] = x[i][j] = 0;
            }
            else if(a[i][j] == 2) {
                r[i][j] = x[i][j] = 0;
            }
            else if(a[i][j] == 3) {
                r[i][j] = d[i][j] = 0;
            }
        }
    }
    cout << ((ll)r[n][m] + (ll)d[n][m] + (ll)x[n][m]) % MOD << endl;
    
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    three[0] = 1;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

