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

int main(){
  int64_t A,B,C;
  cin >> A >> B >> C;

  constexpr int64_t MOD= 10;
  if(B==1){
    cout << A% MOD << endl;
    return 0;
  }
  if(B<= MOD and C<= 4){
    int64_t B_C= 1;
    for(int i=0; i<C; i++){
      B_C*= B;
    }

    int64_t calcA= 1;
    for(int i=0; i<B_C; i++){
      calcA*= A;
      calcA%= MOD;
    }
    cout << calcA << endl;
    return 0;
  }

  constexpr int64_t nil= -1;
  vector<int64_t> memo(MOD, nil);
  map<int, int64_t> digit;
  int64_t calcA= A% MOD;
  int i= 1;
  while(memo.at(calcA)==nil){
    memo.at(calcA)= i;
    digit[i]= calcA;
    i++;
    calcA*= A;
    calcA%= MOD;
  }
  int64_t offset= memo.at(calcA);
  int64_t L= i- memo.at(calcA);

  int64_t B_C_MOD_L= 1;
  int64_t powB= B;
  while(C > 0){
    if(C&1){
      B_C_MOD_L*= powB;
      B_C_MOD_L%= L;
    }

    powB*= powB;
    powB%= L;
    C>>= 1;
  }
  int64_t ans= digit.at((B_C_MOD_L+(L- offset))% L+ 1);

  cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define em emplaces
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
const ll Mod = 998244353;

int n, m;
ll f[5010];
ll invf[5010];

ll dp[15][5010];

ll inv(ll a) {
    ll b = Mod - 2;
    ll ret = 1;
    while(b) {
        if(b & 1) ret *= a;
        b >>= 1;
        a *= a;
        ret %= Mod;
        a %= Mod;
    }

    return ret;
}

int main() {
    fast;

    f[0] = 1;
    for(int i=1; i<=5000; i++) {
        f[i] = f[i-1] * i % Mod;
    }
    invf[5000] = inv(f[5000]);
    for(int i=5000; i>=1; i--) {
        invf[i-1] = invf[i] * i % Mod;
    }

    cin >> n >> m;

    dp[12][0] = 1;
    for(int i=11; i>=0; i--) {
        for(int j=0; j<=m; j++) {
            for(int k=0; k * (1<<i) <= j && k <= n; k+=2) {
                dp[i][j] += dp[i+1][j - k * (1<<i)] * f[n] % Mod * invf[k] % Mod * invf[n-k] % Mod;
                dp[i][j] %= Mod;
            }
        }
    }

    cout << dp[0][m];
}