#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, init, end) for(ll i = init; i < end; i++)
#define REP(i, init, end) for(ll i = init; i < end + 1; i++)
#define rev(i, end, init) for(ll i = init - 1; i >= end; i--)
#define REV(i, end, init) for(ll i = init; i >= end; i--)
#define PI 3.14159265359
#define EPS 0.0000000001
// #define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


#define MOD 998244353

ll dp[10001][10001];
char g[10001][10001];

// 累乗mod
ll pmod(ll n, ll m){
    if(m <= 0) return 1;
    if(m == 1) return n % MOD;
    if(m % 2 == 0){
        return pmod(n * n % MOD, m / 2) % MOD;
    }
    return n * pmod(n * n % MOD, (m - 1) / 2) % MOD;
}

int main(){
    ll H, W, K;
    cin >> H >> W >> K;

    rep(i, 1, 10001){
        rep(j, 1, 10001){
            dp[i][j] = 0;
            g[i][j] = 'E';
        }
    }

    ll h, w;
    char c;
    rep(i, 0, K){
        cin >> h >> w >> c;
        g[h][w] = c;
    }
    if(g[H][W] != 'E'){
        dp[H][W] = 1;
    }else{
        dp[H][W] = 3;
    }

    ll counter = 0;
    ll multCount = 1;
    ll multEmpty;
    ll multElse;
    rev(d, 0, (H - 1) + (W - 1)){//cout << "test: " << d << endl;
        multCount = 0;

        REP(k, 0, d){
            if(d - k <= H - 1 && k <= W - 1 && g[d - k + 1][k + 1] == 'E'){
                multCount++;
            }
        }
        multEmpty = pmod(3, multCount - 1) * 2;
        multElse = pmod(3, multCount);
        REP(k, 0, d){
            counter = 0;
            if(d - k <= H - 1 && k <= W - 1){
                if(g[d - k + 1][k + 1] != 'R'){
                    counter += dp[d - k + 1 + 1][k + 1];
                }
                if(g[d - k + 1][k + 1] != 'D'){
                    counter += dp[d - k + 1][k + 1 + 1];
                }
                counter %= MOD;
                if(g[d - k + 1][k + 1] == 'E'){
                    dp[d - k + 1][k + 1] = (counter * multEmpty) % MOD;
                }else{
                    dp[d - k + 1][k + 1] = (counter * multElse) % MOD;
                }
                // cout << "update: i=" << d - k + 1 << ", j=" << k + 1 << ", dp=" << dp[d - k + 1][k + 1] << endl;
            }
        }
    }

    // REP(i, 1, 3){
    //     REP(j, 1, 3){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }


    cout << dp[1][1] << endl;

    return 0;
}

#ifdef _DEBUG
#include "../../../library/src/debug_template.hpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
constexpr int INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
    init() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} init_;

template<const int &Modulo>
struct Mint {

    lint val;
    constexpr Mint(lint v = 0) noexcept: val(v % Modulo) { if (val < 0) val += Modulo; }

    constexpr Mint &operator+=(const Mint &r) noexcept {
        val += r.val;
        if (val >= Modulo) val -= Modulo;
        return *this;
    }
    constexpr Mint &operator-=(const Mint &r) noexcept {
        val -= r.val;
        if (val < 0) val += Modulo;
        return *this;
    }
    constexpr Mint &operator*=(const Mint &r) noexcept {
        val = val * r.val % Modulo;
        return *this;
    }
    constexpr Mint &operator/=(const Mint &r) noexcept {
        lint a{r.val}, b{Modulo}, u{1}, v{0};
        while (b) {
            lint t = a / b;
            a -= t * b;
            a ^= b, b ^= a, a ^= b;
            u -= t * v;
            u ^= v, v ^= u, u ^= v;
        }
        val = val * u % Modulo;
        if (val < 0) val += Modulo;
        return *this;
    }

    constexpr Mint operator+(const Mint &r) const noexcept { return Mint(*this) += r; }
    constexpr Mint operator-(const Mint &r) const noexcept { return Mint(*this) -= r; }
    constexpr Mint operator*(const Mint &r) const noexcept { return Mint(*this) *= r; }
    constexpr Mint operator/(const Mint &r) const noexcept { return Mint(*this) /= r; }

    constexpr Mint operator-() const noexcept { return Mint(-val); }

    constexpr bool operator==(const Mint &r) const noexcept { return val == r.val; }
    constexpr bool operator!=(const Mint &r) const noexcept { return !((*this) == r); }
    constexpr bool operator<(const Mint &r) const noexcept { return val < r.val; }

    constexpr friend ostream &operator<<(ostream &os, const Mint<Modulo> &x) noexcept { return os << x.val; }
    constexpr friend istream &operator>>(istream &is, Mint<Modulo> &x) noexcept {
        lint tmp{};
        is >> tmp;
        x = Mint(tmp);
        return is;
    }

    [[nodiscard]] constexpr Mint pow(lint n) const noexcept {
        Mint res{1}, tmp{*this};
        while (n > 0) {
            if (n & 1) res *= tmp;
            tmp *= tmp;
            n >>= 1;
        }
        return res;
    }
};

constexpr int MOD = 998244353;
using mint = Mint<MOD>;

int RMOD;
using rmint = Mint<RMOD>;

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
    return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

    int H, W, K;
    cin >> H >> W >> K;

    auto grid = make_vec(H, W, char{});
    auto dp = make_vec(H, W, mint{});
    for (int i = 0; i < K; i++) {
        int h, w;
        char c;
        cin >> h >> w >> c;
        h--, w--;
        grid[h][w] = c;
    }
    DMP(grid);

    dp[0][0] = mint(3).pow(H * W - K);
    constexpr mint z = mint(2) / 3;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            mint r = grid[i][j] == char{} ? z : 1;
            if (j + 1 < W && grid[i][j] != 'D') dp[i][j + 1] += r * dp[i][j];
            if (i + 1 < H && grid[i][j] != 'R') dp[i + 1][j] += r * dp[i][j];
        }
    }
    DMP(dp);

    cout << dp.back().back() << '\n';

    return 0;
}
