https://www.acmicpc.net/problem/1009
#include <iostream>
using namespace std;
int main() {
int n,a,b;
cin>>n;
for(int i=0;i<n;i++){
cin>>a>>b;
int num=1;
for(int j=0;j<b;j++) num=(num*a)%10;
if(num==0) num=10;
cout<<num<<'\n';
}
}