#include <bits/stdc++.h>

typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            998244353
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
#define mem0(x)        memset(x,0,sizeof x)
#define mem1(x)        memset(x,-1,sizeof x)
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.f << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NITIN
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
int power(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m) {
    return power(a, m - 2, m);
}
void solve() {
    int n,m,t;
    cin>>n>>m>>t;
    int inv=modi(3,mod);
    char a[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]='?';
        }
    }
    for(int p=0;p<t;p++) {
        int i, j;
        char c;
        cin >> i >> j >> c;
        --i;
        --j;
        a[i][j] = c;
    }
    int dp[n][m];
    mem0(dp);
    dp[0][0]=power(3,n*m-t,mod);
    for(int i=1;i<n;i++){
        if(a[i-1][0]=='?')
            dp[i][0]=(((dp[i-1][0]*2)%mod)*inv)%mod;
        if(a[i-1][0]=='X' || a[i-1][0]=='D')
            dp[i][0]=dp[i-1][0];
    }
    for(int j=1;j<m;j++){
        if(a[0][j-1]=='?')
            dp[0][j]=(((dp[0][j-1]*2)%mod)*inv)%mod;
        if(a[0][j-1]=='X' || a[0][j-1]=='R')
            dp[0][j]=dp[0][j-1];
    }
    for(int i=1;i< n;i++) {
        for (int j = 1; j < m; j++) {
            int l=0,r=0;
            if (a[i - 1][j] == '?')
                (l += (((dp[i - 1][j] * 2)%mod)*inv)%mod)%=mod;
            if (a[i - 1][j] == 'X' || a[i - 1][j] == 'D')
                (l += dp[i - 1][j])%=mod;
            if (a[i][j - 1] == '?')
               ( r += (((dp[i][j - 1] * 2)%mod)*inv)%mod)%=mod;
            if (a[i][j - 1] == 'X' || a[i][j - 1] == 'R')
                (r += dp[i][j - 1])%=mod;
            (dp[i][j]=l+r)%=mod;
        }
    }
//    for(int i=0;i<n;i++){
//        for(int j=0;j<m;j++){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    cout<<dp[n-1][m-1]<<endl;
}

int32_t main() {
    nitin;

    solve();
}
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ostream &operator<<(ostream &os, const vector<lli> &x){
    os << "{";
    for(int i = 0; i < x.size(); i++){
        if(i < x.size()-1) os << x[i] << ", ";
        else os << x[i];
    }
    os << "}";
    return os;
}
const lli mod = 998244353;
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

int main(void){
    lli h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> m(h, vector<char>(w, '.'));
    rep(i, k){
      lli hi, wi;
      char ci;
      cin >> hi >> wi >> ci;
      hi--;
      wi--;
      m[hi][wi] = ci;
    }
    vector<vector<modint>> dp(h+1, vector<modint>(w+1));
    dp[0][0] = 1;
    modint v3 = 3;
    modint inv3 = v3.inverse();
    rep(i, h){
      rep(j, w){
        if(m[i][j] == 'R'){
          dp[i][j+1] += dp[i][j];
        }else if(m[i][j] == 'D'){
          dp[i+1][j] += dp[i][j];
        }else if(m[i][j] == 'X'){
          dp[i][j+1] += dp[i][j];
          dp[i+1][j] += dp[i][j];
        }else{
          dp[i][j+1] += dp[i][j]*inv3*2;
          dp[i+1][j] += dp[i][j]*inv3*2;
        }
      }
    }
    modint tmp = 3;
    modint ans = dp[h-1][w-1]*(tmp.pow(h*w-k));
    cout << ans << endl;
    return 0;
}
