#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
//#define per(i,a,n) for (int i=n-1;i>=a;i--)
// #define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
ll MOD=9;
ll mod=9;
//const llint MOD;
const ll N=(ll)(1e6+1);
const ll mx=1e7;
const int inf=10000;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
bool prime[mx];
void sieve() {for(int i=2;i<mx;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
vector<ll> primes;
void primecalc(){for(int i=2;i<=mx;i++){
		if(prime[i])
	{
		primes.pb(i);
	}
	if (primes.size()==(int)5e5){break;}
}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
 vector <pair<ll,ll>> prifac;  
 void primefac(ll n){int state=0;while (n % 2 == 0){n = n/2;state++;} if (state) prifac.pb({2,state});for (ll i = 3; i <= sqrt(n); i = i + 2) { state=0;while (n % i == 0){state++;n = n/i;}  if (state) prifac.pb({i,state});}  if (n > 2)  prifac.pb({n,1});}  
  	
//head==================================================================================
// in greedy if comparison see weight or diff


int main(){

 ll a,b,c;
 cin>>a>>b>>c;
primefac(a); 
ll ans=1;
ll h=phi(10);
mod=h;
MOD=h;
ll op=powmod(b,c);
for ( auto x : prifac)
{  
    if (x.first==2){
    	ll k=5;
    	ll io=phi(k);
    	ll nn=1;
    	mod=io;
    	MOD=io;
    	ll exp=powmod(b,c);
    	exp=mul(exp,x.second);
    	exp=exp+io-1;
    	 mod=phi(10);
    mod=10;
    MOD=10;
    ll tu=powmod(x.first,exp);
    tu=mul(tu,2);
    ans=mul(ans,tu);
    }
   else  if (x.first==5){
    	ll k=2;
    	ll io=phi(k);
    	ll nn=1;
    	mod=io;
    	MOD=io;
    	ll exp=powmod(b,c);
    	exp=mul(exp,x.second);
    	exp=exp+io-1;
    	 mod=phi(10);
    mod=10;
    MOD=10;
    ll tu=powmod(x.first,exp);
    tu=mul(tu,5);
    ans=mul(ans,tu);
    }
    else
    {
    	
    mod=phi(10);
    MOD=phi(10); 
	ll tu=mul(x.second,op);
    mod=10;
    MOD=10;
    tu=powmod(x.first,tu);
    ans=mul(ans,tu);
} }
cout<<ans;
 }

//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // 
#include <vector> //
#include <algorithm> // 
#include <queue> // 
#include <string> // 
#include <functional> // 
#include <set> // 
#include <unordered_map> // 
#include <random> // 
#include <ctime> // 
#include <bitset> // 
#include <cassert>

// #include <atcoder/all>
// using namespace atcoder;
// g++ t.cpp -o t -I .

#define DB cerr<<"D"<<endl

struct _zo{_zo(){std::cin.tie(nullptr);std::cout.tie(nullptr);std::ios::sync_with_stdio(false);}}__zo;
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
using P=pair<ll,ll>;
using Q=pair<pair<ll,ll>,ll>;
const ll M = 998244353;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll mod_pow(ll x, ll a, ll m) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;} bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  ll a,b,c;cin>>a>>b>>c;
  a %= 10;
  vector<ll> p[10];
  p[0] = vector<ll>({0});
  p[1] = vector<ll>({1});
  p[2] = vector<ll>({2,4,8,6});
  p[3] = vector<ll>({3,9,7,1});//3,9,27,81
  p[4] = vector<ll>({4,6});//4,16,64
  p[5] = vector<ll>({5});//5,25
  p[6] = vector<ll>({6});//6,36
  p[7] = vector<ll>({7,9,3,1});//7,49,3,1,7
  p[8] = vector<ll>({8,4,2,6});//8,64,512,6,8
  p[9] = vector<ll>({9,1});//9,81,729,

  /*
  if (p[a].size() == 1) {
    cout<<a<<endl;
  } else if (p[a].size() == 2) {
    if (b%2==0) cout<<p[a][1]<<endl;
    else cout<<a<<endl;
  } else {
    // b^c mod 4 = ?
  }*/
  ll dv = p[a].size();
  ll id = mod_pow(b%dv,c,dv);
  //cout<<dv<<" "<<id<<endl;
  id=(id-1+dv)%dv;
  cout<<p[a][id]<<endl;
}
// 

// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest
