#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i VI; typedef vector VVI; int main() { string N,M; cin>>N>>M; int n = N.back() - '0'; int m = 0; if(SZ(M) >= 3) { M = M.substr(SZ(M) - 3); m += 100; }else{ m = atoi(M.c_str()); } int ans = 1; FOR(i,m) ans = (ans * n) % 10; cout<