#include <cstdio>
using namespace std;
typedef long long i64;

char print(int x)
{
    if(x>=0 && x<=9)return x + '0';
    return x+55;
}
i64 qpower(i64 a, i64 b, i64 mod)
{
        i64 res = 1;
        while(b)
        {
            if(b & 1) res = a * res % mod;
            b >>= 1;
            a = a * a % mod;
        }
        return res;
}
double bbp(int n,i64 k,i64 b)
{
    double res = 0;
    for(int i=0;i<=n;i++)
    {
        res += (qpower(16,n-i,8*i+b) * 1.0/(8*i+b));
    }

    for(int i = n + 1;i <= n + 1000 + 1;i++)
    {
        res += (powf(16,n-i)* 1.0/(8*i+b));
    }
    return k * res;
}

int main()
{
    int t,n;
    cin>>t;
    int cas = 1;
    while(t--)
    {
        double ans = 0;
        cin>>n;
        n--;
        ans = bbp(n,4,1) - bbp(n,2,4) - bbp(n,1,5) - bbp(n,1,6);
        ans = ans - (int)ans;
        if(ans<0)ans+=1;
        ans*=16;
        char c ;
        c = print(ans);
        printf("Case #%d: %d %c\n",cas++,n+1,c);
    }
    return 0;
 }
