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

#define ll long long
#define ld long double
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define precision cout << fixed << setprecision(15);

const int inf = 1e9;
const long long INF = 1e18;
int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
clock_t time_p = clock();

void ktj() {
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre() {}

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

void solve() {
  long long a, b, c;
  cin >> a >> b >> c;
  mod = 100;
  long long e = modexpo(b, c);
  mod = 10;
  if (e == 0) {
    cout << modexpo(a, 4) << '\n';
  } else {
    long long f = modexpo(a, e);
    cout << f << '\n';
  }
}

#define GOOGLE 0
#define MULTIPLE_TC 0

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;

  if (MULTIPLE_TC)
    cin >> t;

  for (T = 1; T <= t; T++) {
    if (GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}
#include <iostream>
#define int long long
using namespace std;

int binpow(int a, int b, int c) {
	int ret = 1;
	while (b) {
		if (b & 1) ret = ret * a % c;
		a = a * a % c;
		b >>= 1;
	}
	return ret % c;
}

signed main()
{
	int a, b, c; cin >> a >> b >> c;
	a %= 10; b %= 4;
	int exp = binpow(b, c, 4);
	if (exp == 0) exp = 4;
	cout << binpow(a, exp, 10);
	return 0;
}
