#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e6+5;
ll quick(ll a,ll b) {
ll ans = 1;
while(b) {
if((b&1))ans=ans*a%1000;
a=a*a%1000;
b>>=1;
}
return ans%1000;
}
int main() {
int t,cnt=1;
double ans1,ans2;
scanf("%d",&t);
while(t--){
double a,b;
cin>>a>>b;
ans1 = quick(a,(ll)b);
ans2 = b*log10(a);
ans2 -=floor(ans2);
ans2 = pow(10,ans2)*100;
printf("Case %d: %03.0lf %03.0lf\n",cnt++,floor(ans2),ans1);
}
return 0;
}