#include <vector>
#include <iostream>

using namespace std;
#define debug puts("pigtoria bling bling ⚡️⚡️");

// https://atcoder.jp/contests/abc195/editorial/897
// tips: and | or , in reverse order.
int main() {
    int N;
    string S, X, T;
    cin >> N >> S >> X;
    bool win;
    vector <vector<bool>> dp(N + 1, vector<bool>(7, false));// t win
    dp[N][0] = true;// 无论之前是什么样子，只要最后是7的base，那么，肯定是T win
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < 7; j++) {
            if (X[i] == 'A') {
                if (dp[i + 1][(j * 10) % 7] && dp[i + 1][((j * 10) + S[i] - '0') % 7]) {
                    dp[i][j] = true;
                }
            } else {
                if (dp[i + 1][(j * 10) % 7] || dp[i + 1][((j * 10) + S[i] - '0') % 7]) {
                    dp[i][j] = true;
                }
            }

        }
    }
    win = dp[0][0];
    if (win) cout << "Takahashi";
    else cout << "Aoki";
    return 0;
}
// problem:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template<typename T> inline void ckmax(T& x, T y) { x = (y > x ? y : x); }
template<typename T> inline void ckmin(T& x, T y) { x = (y < x ? y : x); }

const int MOD = 998244353;

inline int mod1(int x) { return x < MOD ? x : x - MOD; }
inline int mod2(int x) { return x < 0 ? x + MOD : x; }
inline void add(int &x, int y) { x = mod1(x + y); }
inline void sub(int &x, int y) { x = mod2(x - y); }
inline int pow_mod(int x, int i) {
	int y = 1;
	while (i) {
		if (i & 1) y = (ll)y * x % MOD;
		x = (ll)x * x % MOD;
		i >>= 1;
	}
	return y;
}

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	if(n == 1) {
		cout << pow_mod(k, m) << '\n';
		return 0; 
	}
	if(m == 1) {
		cout << pow_mod(k, n) << '\n';
		return 0;
	}
	int ans = 0;
	for(int x = 1; x <= k; ++x) {
		int a = pow_mod(x, n);
		sub(a, pow_mod(x - 1, n));
		int b = pow_mod(k - x + 1, m);
		int val = (1ll * a * b) % MOD;
		add(ans, val);
	}
	cout << ans << '\n';
}