#pragma GCC optimize("O3")

#include "bits/stdc++.h"

#define sz(x) (int)(x).size()
using namespace std;
const int64_t INV = int64_t(332748118);
const int64_t MOD = int64_t(998244353);
const int mxN = int(5e3) + 5;
int64_t dp[mxN][mxN];
char arr[mxN][mxN];
int h,w,k;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> h >> w >> k;
    for(int i=0; i<k; i++) {
        int r,c; char val;
        cin >> r >> c >> val;
        arr[r][c] = val;
    }
    dp[1][1] = 1;
    for(int i=1; i<=h; i++)
        arr[i][0] = 'X';
    for(int j=1; j<=w; j++)
        arr[0][j] = 'X';
    for(int i=1; i<=h; i++) {
        for(int j=1; j<=w; j++) {
            if(i==1 && j==1) continue;
            switch(arr[i-1][j]) {
                case 0:
                    dp[i][j] += (2 * INV * dp[i-1][j]) % MOD;
                    break;
                case 'X':
                case 'D':
                    dp[i][j] += dp[i-1][j];
                    break;
            }
            switch(arr[i][j-1]) {
                case 0:
                    dp[i][j] += (2 * INV * dp[i][j-1]) % MOD;
                    break;
                case 'X':
                case 'R':
                    dp[i][j] += dp[i][j-1];
                    break;
            }
        }
    }
    int times = h * w - k;
    int64_t mul = 1;
    while(times--) {
        mul *= 3;
        mul %= MOD;
    }
    cout << (dp[h][w] * mul) % MOD << "\n";

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

const ll INFLL = 1e18;
const int MAXN = 3e5+100;
const ll INF = 1e9;
const int mod1 = 998244353;
const int mod2 = 1e9+21;
int add(int a,int b)
{
    a+=b;
    if (a>=mod1)
        return a-mod1;
    return a;
}

int mult(int a,int b)
{
    return 1ll*a*b%mod1;
}
void ad(int &x,int y)
{
    x=add(x,y);
}
int sub(int a,int b)
{
    a-=b;
    if (a<0)
        return a+mod1;
    return a;
}

int bin_pow(int base,ll deg)
{
    if (deg==0)
        return 1;
    int t=bin_pow(base,deg/2);
    if (deg&1)
        return 1ll*t*t%mod1*base%mod1;
    else
        return 1ll*t*t%mod1;
}
void solve()
{
    int h,w,k;
    cin>>h>>w>>k;
    vector <vector <char> > c(h,vector <char>(w,'1'));
    while (k--)
    {
        int x,y;
        cin>>x>>y;
        x--,y--;
        cin>>c[x][y];
    }
    vector <int> pows(MAXN);
    pows[0]=1;
    for (int i=1;i<MAXN;i++)
        pows[i]=mult(3,pows[i-1]);
    vector <vector <int> > pref(h+1,vi(w+1));
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
            pref[i][j]=pref[i][j-1]+(c[i-1][j-1]=='1'?1:0);
    }
    for (int j=1;j<=w;j++)
    {
        for (int i=1;i<=h;i++)
            pref[i][j]+=pref[i-1][j];
    }
    auto get = [&](int x,int y,int x1,int y1)
    {
        x++,y++,x1++,y1++;
        if (x>h||y>w)
            return 1;
        int ans=pref[x1][y1];
        ans+=pref[x-1][y-1];
        ans-=pref[x1][y-1];
        ans-=pref[x-1][y1];
        return pows[ans];
    };
    vector <vector <int> > dp(h,vi(w));
    dp[0][0]=1;
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++)
        {
            if (c[i][j]=='1')
            {
                if (i+1<h)
                    ad(dp[i+1][j],mult(mult(2,get(i,j+1,i,w-1)),dp[i][j]));
                if (j+1<w)
                    ad(dp[i][j+1],mult(mult(2,get(i+1,j,h-1,j)),dp[i][j]));
            }
            else if (c[i][j]=='R')
            {
                if (j+1<w)
                    ad(dp[i][j+1],mult(mult(1,get(i+1,j,h-1,j)),dp[i][j]));
            } else if (c[i][j]=='D')
            {
                if (i+1<h)
                    ad(dp[i+1][j],mult(mult(1,get(i,j+1,i,w-1)),dp[i][j]));
            }
            else{
                if (j+1<w)
                    ad(dp[i][j+1],mult(mult(1,get(i+1,j,h-1,j)),dp[i][j]));
                if (i+1<h)
                    ad(dp[i+1][j],mult(mult(1,get(i,j+1,i,w-1)),dp[i][j]));
            }
        }
    }
    cout<<mult(dp[h-1][w-1],c[h-1][w-1]=='1'?3:1);
    // X?
    // RR
}

int main() {
    #ifdef Mip182
    freopen("a.in", "r", stdin);
    #else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    int _t;
    _t=1;
//    cin>>_t;
    while (_t--)
        solve();
    #ifdef Mip182
    cout<<'\n'<<"Time : "<<(double)(clock())/CLOCKS_PER_SEC<<'\n';
    #endif
}
