#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/rational.hpp>

// using bigint = boost::multiprecision::cpp_int;
// using fraction = boost::rational<bigint>;
using namespace std;

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 998244353;
unused constexpr ll INF = 1 << 30;
unused constexpr ll LINF = 1LL << 62;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused inline bool in_range(T a, T x, T b) { return a <= x && x < b; }
unused inline bool in_range(ll x, ll b) { return in_range(0LL, x, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

pair<vector<ll>, ll> modloopvector(ll a, ll m) {
    set<ll> s; vector<ll> v;
    ll tmp = 1;
    while(!s.count(tmp)) {
        s.insert(tmp);
        v.push_back(tmp);
        tmp = mod(tmp * a, m);
    }
    int loop_start_idx 
            = distance(v.begin(), find(v.begin(), v.end(), tmp));
    return {v, loop_start_idx};
}

ll modpow(ll a, ll n, ll m = MOD){
    ll ret = 1;
    while(n>0){
        if(n&1) ret = (ret * a) % m;
        a = (a * a) % m;
        n >>= 1;
    }
    return ret % m;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    
    auto [v, idx] = modloopvector(a, 10);
    int cycle = (int)v.size() - idx;

    ll bc = 1;
    rep(i, c) {
        bc *= b;
        if(bc >= idx) break;
    }

    ll ans;
    if(bc < idx) {
        ans = v[bc];
    } else {
        ll tmp = modpow(b, c, cycle);
        tmp = mod(tmp - idx, cycle) + idx;
        ans = v[tmp];
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)

int n, h, w, a, b, ans = 0;
int p[20][20];

main() {
    cin >> h >> w >> a >> b;
    n = h * w;
    ans = 0;
    rep(mask, 0, (1 << n)) {
        if ((int)__builtin_popcount(mask) == a) {
            rep(subm, 0, (1 << a)) {
                int j = 0;
                rep(i, 0, n) {
                    int x = i / w, y = i % w;
                    if ((mask >> i) & 1) {
                        p[x][y] = (subm >> j) & 1;

                        ++j;
                    } else {
                        p[x][y] = -1;
                    }
                }
                assert(j == a);
                int flag = 1;
                rep(x, 0, h) rep(y, 0, w) {
                    if (p[x][y] == 0) {
                        if (y == w - 1 || p[x][y + 1] != -1 || (x > 0 && p[x - 1][y + 1] == 1)) {
                            flag = 0;
                            break;
                        }
                    }
                    if (p[x][y] == 1) {
                        if (x == h - 1 || p[x + 1][y] != -1 || (y > 0 && p[x + 1][y - 1] == 0)) {
                            flag = 0;
                            break;
                        }
                    }
                }
                ans += flag;
            }
        }
    }
    cout << ans << '\n';
}