#include <bits/stdc++.h>

#define int long long

using namespace std;

const int maxn = 5005;
const int mod = 998244353;
int h, w, k;
char grid[maxn][maxn];
int dp[maxn][maxn], d[maxn][maxn], r[maxn][maxn], p[maxn];

int recur(int i, int j) {
    if (dp[i][j] != -1) return dp[i][j];
    if (i == h && j == w) {
        if (grid[i][j] == '.') return 3;
        else return 1;
    }
    int res = 0;
    // move down
    if (grid[i][j] != 'R' && i != h) {
        int ways = p[(w-j)-r[i][j+1]];
        if (grid[i][j] == '.') ways = (ways*2)%mod;
        res += (recur(i+1,j)*ways)%mod;
        res %= mod;
    }
    // move right
    if (grid[i][j] != 'D' && j != w) {
        int ways = p[3,(h-i)-d[i+1][j]];
        if (grid[i][j] == '.') ways = (ways*2)%mod;
        res += (recur(i,j+1)*ways)%mod;
        res %= mod;
    }
    dp[i][j] = res;
    return res;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    p[0] = 1;
    for (int i = 1; i < maxn; i++) p[i] = (p[i-1]*3)%mod;
    for (int i = 0; i < maxn; i++) for (int j = 0; j < maxn; j++) {
        grid[i][j] = '.';
        dp[i][j] = -1;
        d[i][j] = r[i][j] = 0;
    }
    cin >> h >> w >> k;
    for (int i = 0; i < k; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        grid[x][y] = c;
        d[x][y]++;
        r[x][y]++;
    }
    for (int i = 0; i < maxn; i++) {
        for (int j = maxn-2; j >= 0; j--) {
            d[j][i] += d[j+1][i];
            r[i][j] += r[i][j+1];
        }
    }
    int res = recur(1,1);
    cout << res << '\n';
}
/*


 */
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<stdio.h>
#include<vector>
#include<algorithm>
constexpr unsigned long long MOD = 998244353;
constexpr unsigned long long IM = 18479187003;
constexpr unsigned long long MOD32 = 665496236;

    unsigned long long dp[5001];
int main(){
    int H=0, W=0, K=0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {H=(H<<1)+(H<<3)+c-'0'; c=getchar_unlocked();}
    c=getchar_unlocked();
    while(c<='9'&&c>='0') {W=(W<<1)+(W<<3)+c-'0'; c=getchar_unlocked();}
    c=getchar_unlocked();
    while(c<='9'&&c>='0') {K=(K<<1)+(K<<3)+c-'0'; c=getchar_unlocked();}
    std::vector<std::vector<std::pair<int, char>>> f(H);
    unsigned long long y = H * W - K;
    while(--K>=0){
        int h=0, w=0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {h=(h<<1)+(h<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {w=(w<<1)+(w<<3)+c-'0'; c=getchar_unlocked();}
        --h; --w;
        f[h].emplace_back(w, getchar_unlocked());
        getchar_unlocked();
    }
    --H; --W;
    dp[0] = 1;
    for(int i = 0; i < H; ++i){
        std::sort(f[i].begin(), f[i].end());
        auto itr = f[i].begin();
 
        for (int j = 0; j <= W; ++j){
            if(itr != f[i].end() and itr->first == j){
                char c = itr->second;
                if(c != 'D') dp[j + 1] += dp[j];
                if(c == 'R') dp[j] = 0;
                ++itr;
            }
            else{
                {
        dp[j] *= MOD32;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(dp[j], IM, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned __int128)(dp[j])*IM) >> 64);
#endif
        dp[j] = dp[j] - x * MOD+MOD;
             }
                dp[j + 1] += dp[j];
            }
        }
    }
  
  {
        std::sort(f[H].begin(), f[H].end());
        auto itr = f[H].begin();
        for (int j = 0; j < W; ++j){
            if(itr != f[H].end() and itr->first == j){
                char c = itr->second;
                if(c != 'D') dp[j + 1] += dp[j];
                ++itr;
            }
            else{
                 {
        dp[j] *= MOD32;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(dp[j], IM, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned __int128)(dp[j])*IM) >> 64);
#endif
        dp[j] = dp[j] - x * MOD+MOD;
             }
                dp[j + 1] += dp[j];
            }
        }
  }

    unsigned long long x = 3;
    while(y) {
      if(y & 1) {
        dp[W] *= x;
#ifdef _MSC_VER
        unsigned long long x2;
        _umul128(dp[W], IM, &x2);
#else
        unsigned long long x2 =
            (unsigned long long)(((unsigned __int128)(dp[W])*IM) >> 64);
#endif
        dp[W] = dp[W] - x2 * MOD+MOD;
               }
      {
        x *= x;
#ifdef _MSC_VER
        unsigned long long x2;
        _umul128(x, IM, &x2);
#else
        unsigned long long x2 =
            (unsigned long long)(((unsigned __int128)(x)*IM) >> 64);
#endif
        x = x- x2 * MOD + MOD;}
      y >>= 1;
    }
    printf("%d", dp[W] % MOD);

    return 0;
}

