#include<bits/stdc++.h>
using namespace std;

int main(){
  int H,W,k;
  cin >> H >> W >> k;
  
  int h[k],w[k];
  char c[k];
  char masu[H + 1][W + 1];
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      masu[i][j] = '-';
    }
  }
  for(int i = 0 ; i < k ; i++){
    cin >> h[i] >> w[i] >> c[i];
    h[i]--; w[i]--;
    masu[h[i]][w[i]] = c[i];
  }
  
  long long beki[10100];
  beki[0] = 1;
  for(int i = 1; i<=10000 ;i++){
    beki[i] = beki[i-1]*3;
    beki[i] %= 998244353;
  }
  
  int yoko[H];
  int tate[W];
  
  long long dp[H + 1][W + 1];
  dp[H - 1][W - 1] = 1;
  
  for(int i = 0 ; i < H ; i++){
    yoko[i] = 0;
    dp[i][W] = 0;
  }
  for(int i = 0 ; i < W ; i++){
    tate[i] = 0;
    dp[H][i] = 0;
  }
  
  for(int i = H - 1 ; i >= 0 ; i--){
    for(int j = W - 1 ; j >= 0 ; j--){
      
      if(i == H - 1 && j == W - 1){
        if(masu[i][j] == '-'){
          dp[i][j] = 3;
          yoko[i] += 1;
          tate[j] += 1;
        }
        if(masu[i][j] != '-')dp[i][j] = 1;
        continue;
      }
      dp[i][j] = 0;
      if(masu[i][j] == 'R'){
        dp[i][j] += beki[tate[j]] * dp[i][j + 1];
        dp[i][j] %= 998244353;
      }
      if(masu[i][j] == 'D'){
        dp[i][j] += beki[yoko[i]] * dp[i + 1][j];
        dp[i][j] %= 998244353;
      }
      if(masu[i][j] == 'X'){
        dp[i][j] += beki[yoko[i]] * dp[i + 1][j];
        dp[i][j] %= 998244353;
        dp[i][j] += beki[tate[j]] * dp[i][j + 1];
        dp[i][j] %= 998244353;
      }
      if(masu[i][j] == '-'){
        dp[i][j] += beki[yoko[i]] * dp[i + 1][j];
        dp[i][j] %= 998244353;
        dp[i][j] += beki[tate[j]] * dp[i][j + 1];
        dp[i][j] %= 998244353;
        dp[i][j] *= 2;
        dp[i][j] %= 998244353;
      }
      dp[i][j] %= 998244353;
      if(masu[i][j] == '-'){
          yoko[i] += 1;
          tate[j] += 1;
      }
    }
  }
  
  cout << dp[0][0];
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

template<typename T>
istream &operator>>(istream &in, vector<T> &x) {
    for (auto &i : x)
        in >> i;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &x) {
    for (auto &i : x) {
        out << i << " ";
    }
    return out;
}

template<typename T, typename D>
istream &operator>>(istream &in, pair<T, D> &x) {
    in >> x.first >> x.second;
    return in;
}

template<typename T, typename D>
ostream &operator<<(ostream &out, const pair<T, D> &x) {
    out << x.first << " " << x.second;
    return out;
}

struct LogOutput {
    template<typename T>
    LogOutput &operator<<(T x) {
#ifdef Dmitry07
        cout << x;
#endif
        return *this;
    }
} dout;

typedef long long ll;
typedef unsigned long long ull;
typedef double dl;

#define nl '\n'
#define elif else if
#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vpi vector<pair<int, int>>
#define eb emplace_back
#define pb push_back
// #define MOD1(x, m) ((x) % m + ((x) < 0  && ((x % m) != 0) ? m : 0))
#define mod(x, m) (((x) % (m) + (m)) % (m))
#define vi vector<int>
#define pi pair<int, int>
#define ti tupMXle<int, int, int>
#define minq(x, y) x = min((x), (y))
#define maxq(x, y) x = max((x), (y))
#define forn(i, n) for (int i = 0; i < (n); ++i)

const ll INFL = 1e15;  // 9187201950435737471;
const ll nINFL = -9187201950435737472;
const int INF = 1e9 + 10;  // 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const dl PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

inline void IO() {
#ifdef Dmitry07
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(15);
}

const int MAXN = 4e5 + 10;
const int MAXE = 1e5 + 10;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int W = 1e6 + 100;
const int K = 1000 + 1;

#define int ll

int tree[4 * MAXN];

void Build(vi &a, int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = a[tl];
        return;
    }
    int tm = (tl + tr) / 2;
    Build(a, v * 2, tl, tm);
    Build(a, v * 2 + 1, tm + 1, tr);
    tree[v] = tree[v * 2] ^ tree[v * 2 + 1];
}

void Upd(int v, int tl, int tr, int pos, int val) {
    if (tl == tr) {
        tree[v] ^= val;
        return;
    }
    int tm = (tl + tr) / 2;
    if (pos <= tm) {
        Upd(v * 2, tl, tm, pos, val);
    } else {
        Upd(v * 2 + 1, tm + 1, tr, pos, val);
    }
    tree[v] = tree[v * 2] ^ tree[v * 2 + 1];
}

int Xor(int v, int tl, int tr, int l, int r) {
    if (l > r) {
        return 0;
    }
    if (tl == l && tr == r) {
        return tree[v];
    }
    int tm = (tl + tr) / 2;
    return Xor(v * 2, tl, tm, l, min(r, tm)) ^
           Xor(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r);
}

void Solve() {
    int n, q;
    cin >> n >> q;
    vi a(n);
    cin >> a;
    Build(a, 1, 0, n - 1);
    while (q--) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            Upd(1, 0, n - 1, x - 1, y);
        } else {
            cout << Xor(1, 0, n - 1, x - 1, y - 1) << nl;
        }
    }
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    int startTime = clock();
    while (t--) {
        Solve();
    }
    int endTime = clock();
    dout << '\n' << "Time: " << (endTime - startTime) / 1000.0;
    return 0;
}
