#include using namespace std; const int MOD=10; int pw(int n,int k){ assert(k>=0); int res=1; while(k){ if(k&1)(res*=n)%=MOD; (n*=n)%=MOD; k>>=1; } return res; } template void fin(T a){ cout<>n>>m; if(m=="0")fin(1); int N=(int)(n.back()-'0'),M=(int)(m.back()-'0'); if(m.size()>=2)M+=10*(int)(m[m.size()-2]-'0'); cout<