#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;

template <typename T1, typename T2>
void mmin(T1& a, const T2& b) {
  if (b < a) a = b;
}

template <typename T1, typename T2>
void mmax(T1& a, const T2& b) {
  if (b > a) a = b;
}

const int MAXN = 5020, P = 998'244'353;
int n, m, k;
char c[MAXN][MAXN];
ll d[MAXN][MAXN];

constexpr ll qpow(ll base, ll exp) {
  ll ans = 1;
  while (exp) {
    if (exp % 2) ans = ans * base % P;
    base = base * base % P;
    exp /= 2;
  }
  return ans % P;
}

constexpr ll two_thirds = qpow(3, P - 2) * 2 % P;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int h, w;
    char q;
    cin >> h >> w >> q;
    c[h][w] = q;
  }

  d[1][1] = qpow(3, n * m - k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (i == 1 && j == 1) continue;
      if (i > 1) {
        if (!c[i - 1][j]) d[i][j] = (d[i][j] + d[i - 1][j] * two_thirds) % P;
        else if (c[i - 1][j] != 'R') d[i][j] = (d[i][j] + d[i - 1][j]) % P;
      }
      if (j > 1) {
        if (!c[i][j - 1]) d[i][j] = (d[i][j] + d[i][j - 1] * two_thirds) % P;
        else if (c[i][j - 1] != 'D') d[i][j] = (d[i][j] + d[i][j - 1]) % P;
      }
    }
  cout << d[n][m] << endl;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
// #define MOD 1000000007
#define MOD 998244353
 
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll N, K;
  string S;
  cin >> N >> K >> S;
  for (ll k = 0; k < K; k++) {
    string T = S;

    for(ll i = 0; i < T.size(); i+=1) {
      char te1 = S[(2*i)%N];
      char te2 = S[(2*i+1)%N];
      if (te1 != te2) {
        if (te1 == 'R') {
          if (te2 == 'S') {
            T[i] = te1;
          } else {
            T[i] = te2;
          }
        } else if (te1 == 'S') {
          if (te2 == 'R') {
            T[i] = te2;
          } else {
            T[i] = te1;
          }
        } else {
          if (te2 == 'R') {
            T[i] = te1;
          } else {
            T[i] = te2;
          }
        }
      } else {
        T[i] = te1;
      }
    }
    S = T;
  }
  cout << S[0] << endl;
  return 0;
} 
