#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define For(i,x,y)	for(ll i=(x);i<=(y);++i)
#define FOr(i,x,y)	for(ll i=(x);i>=(y);--i)
#define rep(i,x,y)	for(ll i=(x);i<(y);++i)
#define clr(a,v)	memset(a,v,sizeof(a))
#define cpy(a,b)	memcpy(a,b,sizeof(a))
#define fi	first
#define se	second
#define	pb	push_back
#define mk	make_pair
#define pa	pair<ll,ll>
#define y1	y11111111111111
#define debug	puts("@@@@@@@@@@@@@@@@@@@@@@@")
ll read(){
	ll x=0,f=1;	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())	x=x*10+ch-'0';
	return x*f;
}
void write(ll x){
	if (x<0)	putchar('-'),write(-x);
	else{
		if (x>=10)	write(x/10);
		putchar(x%10+'0');
	}
}

ll a[11][11],m[11];

inline ll ksm(ll x,ll n,ll m){
	ll ans = 1;
	while(n){
		if(n&1) ans = ans*x%m;
		x = x*x%m;
		n >>= 1;
	}
	return ans;
}

signed main(){
	For(i,0,9){
		a[i][++m[i]] = i;
		ll x = i*i%10;
		while(x != i){
			a[i][++m[i]] = x;
			x = x*i%10;
		}
	}
	ll A = read(),B = read(),C = read();
	A = A%10;
	ll p = ksm(B,C,m[A]);
	if(p == 0) p = m[A];
	printf("%lld\n",a[A][p]);
}
#include <bits/stdc++.h>
#define ll long long
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FOR(i, a, b) for (int i=a; i<(b); i++)
using namespace std;

ll mod = 998244353;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
    ll a,b,c;
    cin >> a >> b >> c;
    ll x1 = (a*(a+1)/2) % mod;
    ll x2 = (b*(b+1)/2) % mod;
    ll x3 = (c*(c+1)/2) % mod;

    ll ans = ((x1*x2%mod)*x3%mod);
    cout << ans << "\n";

    return 0;
}