#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
using ll = long long;

const int mod = 998244353;
int n, m, k;
ll dp[5000][5000];
string a[5000];

ll modpow(ll x, ll y){
    if(!y) return 1;
    ll res = modpow(x, y / 2);
    res = (res * res) % mod;
    if(y % 2) res = (res * x) % mod;
    return res;
}  

int main(){
    //IO("input.txt", "output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) a[i] = string(m, ' ');
    for(int i = 0; i < k; i++){
        int h, w;
        char c;
        cin >> h >> w >> c;
        a[h - 1][w - 1] = c;
    }
    dp[0][0] = modpow(3, n * m - k);
    int inv = modpow(3, mod - 2);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if(i == n - 1 && j == m - 1) cout << dp[i][j] << '\n';
            else if(a[i][j] == ' '){
                if(i + 1 < n)
                    dp[i + 1][j] = (dp[i + 1][j] + ((dp[i][j] * 2) % mod * inv) % mod) % mod;
                if(j + 1 < m)
                    dp[i][j + 1] = (dp[i][j + 1] + ((dp[i][j] * 2) % mod * inv) % mod) % mod;
            }else{
                if(i + 1 < n && (a[i][j] == 'X' || a[i][j] == 'D'))
                    dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
                if(j + 1 < m && (a[i][j] == 'X' || a[i][j] == 'R'))
                    dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
            }
    return 0;
}

/*
for a path:
3 ^ (nm - k - empty_in_path) * 2 ^ (empty_in_path)
dp[i + 1][j]
 XD
D D
R 
*/
#include <iostream>
#include <vector>
#define ll long long
#define mod % 998244353
#define UNUSE 998244354991

using namespace std;

vector<ll> multi(int a){
  vector<ll> ans(a+1);
  ans[0] = 1;
  for(int i = 0;i < a;i ++){
    ans[i+1] = (ans[i]*3) mod;
  }
  return ans;
}
int main(void){
  int high,wide;
  cin >> high;
  cin >> wide;
  int kaki;
  cin >> kaki;
  vector<vector<char>> bo(high,vector<char>(wide,'N'));
  for(int i = 0;i < kaki;i ++){
    int p,q;
    char r;
    cin >> p;
    cin >> q;
    cin >> r;
    bo[p-1][q-1] = r;
  }
  vector<vector<ll>> ans(high+1,vector<ll>(wide+1,0));
  vector<vector<ll>> rem(high+1,vector<ll>(wide+1,UNUSE ));
  ans[0][0] = 1;
  rem[0][0] = high*wide-kaki;
  
  vector<ll> multis = multi(high*wide-kaki);
  
  
  for(int i = 0;i < high;i ++){
    for(int j = 0;j < wide;j ++){
      if(i == high-1 and j == wide-1){
        break;
      }
      if(ans[i][j] == 0){
        continue;
      }
      if(bo[i][j] == 'N'){
        rem[i][j] --;
        ans[i][j] = (ans[i][j] * 2) mod;
        bo[i][j] = 'X';
      }
      if(bo[i][j] == 'D' or bo[i][j] =='X'){
        rem[i+1][j] = rem[i][j];
        ans[i+1][j] = ans[i][j] mod;
      }
      if(bo[i][j] == 'R' or bo[i][j] == 'X'){
        ll mult;
        if(rem[i][j+1] != UNUSE){
        if(rem[i][j] > rem[i][j+1]){
          mult = multis[rem[i][j]-rem[i][j+1]];
          ans[i][j+1] = (mult * ans[i][j] + ans[i][j+1]) mod;
        }else{
          mult = multis[rem[i][j+1] - rem[i][j]];
          rem[i][j+1] = rem[i][j];
          ans[i][j+1] = (mult*ans[i][j+1] + ans[i][j]) mod;
 
        }
        }else{
        rem[i][j+1] = rem[i][j];
          ans[i][j+1] = ans[i][j] mod;
        }
        
      }
      
    }
  }
ll fina;
  if(rem[high-1][wide-1] == UNUSE){
    fina = 0;
  }else{
  fina = (ans[high-1][wide-1] * multis[rem[high-1][wide-1]]) mod;
}
  cout << fina << endl;
                                     
  
  
  return 0;
}