#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define ref goto refrain

class dice{
	public:
	int o,u,s,e,n,w;//over,under,south,east,north,west
	void change(char a);
};
void dice::change(char a){
	int tem=o;
	if(a=='S'){
		o=n;	n=u;	u=s;	s=tem;
	}
	else if(a=='E'){
		o=w;	w=u;	u=e;	e=tem;
	}
	else if(a=='N'){
		o=s;	s=u;	u=n;	n=tem;
	}
	else if(a=='W'){
		o=e;	e=u;	u=w;	w=tem;
	}
	else{
		cout<<"Error!"<<endl;
		exit(0);
	}
}
		

int main(){
	dice a;
	cin>>a.o>>a.s>>a.e>>a.w>>a.n>>a.u;
	char com[100];
	cin>>com;
	int m=strlen(com);
	for(int i=0;i<m;i++){
		a.change(com[i]);
	}
	cout<<a.o<<endl;
	return 0;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 2e5+5, MOD = 998244353;
int n, m, k, p[N];

int mul(int x, int y) {
    ll tmp = 1LL * x * y;
    return tmp % MOD;
}
int add(int x, int y) {
    ll tmp = 1LL*x + 1LL*y;
    return tmp % MOD;
}
int pow(int x, int e) {
    int res = 1;
    for(; e; e>>=1) {
        if(e&1) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}
int inv(int x) {
    return pow(x, MOD-2);
}
int C(int x, int y) {
    int det = mul(p[x], p[y-x]);
    return mul(p[y], inv(det));
} 
void preprocess() {
    p[0] = 1;
    for(int i=1; i<N; i++)
        p[i] = mul(p[i-1], i);
}
int main() {
    preprocess();
    cin >> n >> m >> k;
    int ans = 0;
    for(int t=n-k; t<=n; t++) {
        int tmp = mul(m, pow(m-1, t-1));
        tmp = mul(tmp, C(n-t, n-1));
        ans = add(ans, tmp);
    }
    cout << ans;
}