/* 前三位 len=log10n^k(乘积的长度) len=klog10n n^k=x*10^(len-1) x=n^k/10^(len-1) log10x = k*log10n - (len-1) x=pow(10,k*log10n - (len-1)) 后三位 快速幂解决 */ #include<bits/stdc++.h> using namespace std; #define ll long long ll n,k,x; ll power(ll a,ll n){ ll res=1; while(n){ if(n%2)res=res*a%1000; a=a*a%1000; n>>=1; } return res%1000; } int main(){ int T; cin>>T; for(int tt=1;tt<=T;tt++){ cin>>n>>k; ll len=k*log10((double)n); double x=pow((double)10,(double)k*log10((double)n)-(len-1)); while(x<100)x*=10; printf("Case %d: %d ",tt,(int)x); n%=1000; ll y=power(n,k);//后三位用快速幂 if(y==0)printf("000 "); else if(y<10)printf("00%d ",y); else if(y<100)printf("0%d ",y); else printf("%d ",y); } }