#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 100005
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int a,b,c,flag,ans;
int Pow(int x,int y,int mod,int &f)
{
	int res=1;
	for(;y;y>>=1,f|=(ll)x*x>=mod,x=(ll)x*x%mod)
		if(y&1) f|=(ll)res*x>=mod,res=(ll)res*x%mod;
	return res;
}
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	b=Pow(b,c,4,flag);
	if(flag) b+=4,flag=0;
	ans=Pow(a,b,10,flag);
	printf("%d\n",ans);
	return 0;
}
#include <bits/stdc++.h>

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0), cout << setprecision(15);
#define ll long long int
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, k, n) for (ll i = k; i>=n; i--)
#define repp(i, k, n) for (ll i = k; i < (n); i++)
#define pb push_back
#define all(x) begin(x), end(x)
#define vc vector<ll>
using namespace std;
using namespace std::chrono;
typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds Milliseconds;

ll mPow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        n = n >> 1;
    }
    return ans % mod;
}

ll fact[1000005];
ll mod = 998244353;

void initialize() {
    ll n = 1000005;
    fact[0] = 1;
    fact[1] = 1;
    repp(i, 2, n) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll ncr(ll a, ll b) {
    ll k = (fact[b] * fact[a - b]) % mod;
    ll g = mPow(k, mod - 2, mod);
    return (fact[a] * g) % mod;
}

void dd() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    ll q = mPow(k, n, mod);
    repp(i, 1, n + 1) {
        ans += ((i) * (ncr(n - 1, i - 1) * ((k * (mPow(k - 1, i - 1, mod))) % mod)) % mod) % mod;
        cout << "Segements: " << i << " NCR " << ncr(n - 1, i - 1) << " WAYS " << k * (mPow(k - 1, i - 1, mod)) << "\n";
        ans %= mod;
    }
    q = mPow(q, mod - 2, mod);
    cout << "Inverse Q " << q << "\n";
    cout << "P " << ans << "\n";
    ans *= q;
    ans %= mod;
    cout << ans << "\n";
}

void d() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    ll q = pow(k, n);
    repp(i, 1, n + 1) {
        ans += (i) * (ncr(n - 1, i - 1) * k * (mPow(k - 1, i - 1, mod)));
        ans %= mod;
    }
    q = mPow(q, mod - 2, mod);
    ans *= q;
    ans %= mod;
    cout << ans << "\n";
}

void atcoder() {
    ll n; cin>>n;
    ll a[n], b[n];
    rep(i, n) cin>>a[i];
    rep(i, n) cin>>b[i];
    ll ans = 0;
    rep(i, n){
        ans+=a[i]*b[i];
    }
    if(ans == 0) cout<<"Yes";
    else cout<<"No";
}

int main() {
    FAST_IO
    ll test = 1;
//    initialize();
//    cin >> test;
    while (test-- > 0) {
        atcoder();
    }
}