// Arup Guha
// 4/15/2023
// Solution to 2023 Code Jam Farewell Round A Problem D: Ascii Art

import java.util.*;

public class d {

	public static void main(String[] args) {
	
		// Pre-comp the length of each string upto index i.
		long[] arr = new long[300000];
		for (long i=1; i<300000; i++)
			arr[(int)i] = i*(i+1)*13;
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
			
			// Get query and get last index before the one where the nth item will print.
			long n = stdin.nextLong();
			int idx = bs(arr, n)-1;
			
			// Get which 0-ranked letter we want in the string with idx+1 letters of each type.
			long prev = arr[idx];
			long need = n-prev-1;
			
			// This is the letter that will print.
			int letter = (int)(need/(idx+1));
			System.out.println("Case #"+loop+": "+(char)('A'+letter));
		}
	}
	
	// returns the smallest index in arr such that arr[i] >= val. arr is sorted...
	public static int bs(long[] arr, long val) {
	
		// Run a binary search for the desired value.
		int low = 1, high = arr.length-1;
		while (low < high) {
			int mid = (low+high)/2;
			
			if (arr[mid] < val)
				low = mid+1;
			else
				high = mid;
		}
		
		return low;
	}
}