package test;
import java.io.*;
import java.math.*;
import java.util.*;
public class test3 {
public static void main(String[] args) throws IOException {
BufferedReader cc = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out));
int t;t = Integer.parseInt(cc.readLine());
for(int cas=1 ; cas<=t ; cas++){
BigInteger aa = new BigInteger(cc.readLine());
BigInteger ans = aa.multiply(aa).multiply(BigInteger.valueOf(8)).subtract(aa.multiply(BigInteger.valueOf(7))).add(BigInteger.valueOf(1));
cout.write("Case #"+cas+": ");
cout.write(ans.toString());
cout.newLine();
}
cout.flush();
cout.close();
}
}