#include<iostream> using namespace std; int main() { unsigned int n,a; cin>>a>>n; a=a%10; if(n%4==1) cout<<a; else if(n%4==2) cout<<a*a%10; else if(n%4==3) cout<<a*a*a%10; else if(n%4==0) cout<<a*a*a*a%10; system("pause"); return 0; }