#include <iostream>
using namespace std;

int h, w, a, b;
int room[18][18];
int cnt;

void putA(int n, int pos) {
	if (n > a) {
		cnt++;
		return;
	}
	for (; pos < h * w; pos++) {
		int r = (pos / w) + 1;
		int c = (pos % w) + 1;
		if (room[r][c] == 0) {
			room[r][c] = n;
			if (room[r][c + 1] == 0) {
				room[r][c + 1] = n;
				putA(n + 1, pos + 1);
				room[r][c + 1] = 0;
			}
			if (room[r + 1][c] == 0) {
				room[r + 1][c] = n;
				putA(n + 1, pos + 1);
				room[r + 1][c] = 0;
			}
			room[r][c] = 0;
		}
	}
}

int main()
{
	cin >> h >> w >> a >> b;

	for (int r = 0; r < h + 2; r++)
		for (int c = 0; c < w + 2; c++)
			room[r][c] = ((r >= 1) && (r <= h) && (c >= 1) && (c <= w)) ? 0 : -1;
	cnt = 0;
	putA(1, 0);
	cout << cnt;
}
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
constexpr int MOD = 998244353;
constexpr int prob = 665496236;
long long dp[5001];

int pow(long long x, int n){
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= MOD;
        x *= x, x %= MOD;
        n >>= 1; 
    }
    return ret;
}

int main(){
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);

    vector<vector<pair<int, char>>> X(H);
    for(int i = 0; i < H; ++i) X[i].reserve(W);

    for(int i = 0; i < K; ++i){
        int x, y;
        char c;
        scanf("%d%d%c%c", &x, &y, &c, &c);
        --x, --y;
        X[x].emplace_back(y, c);
    }

    dp[0] = 1;
    for(int i = 0; i < H; ++i){
        sort(X[i].begin(), X[i].end());
        auto itr = X[i].begin();

        for (int j = 0; j < W; ++j){
            dp[j] %= MOD;
            if(itr != X[i].end() and itr->first == j){
                char c = itr->second;
                if(c != 'D') dp[j + 1] += dp[j];
                if((i != H - 1) & c == 'R') dp[j] = 0;
                ++itr;
            }
            else{
                dp[j + 1] += dp[j] * prob;
                if(i != H - 1) dp[j] *= prob;
            }
        }
    }

    long long ans = dp[W - 1];
    ans *= pow(3, H * W - K);
    printf("%d", ans % MOD);

    return 0;
}

