import math Tc = int(input()) def compute_grouping(N): temp = math.floor((N / 13)**0.5 - 1) for t in range(temp, temp + 5): if 13 * t * (t + 1) >= N: return t def compute(N): n = compute_grouping(N) N -= 13 * (n - 1) * n if N % n == 0: return chr(ord('A') - 1 + N // n) else: return chr(ord('A') + N // n) for t in range(Tc): N = int(input()) print(f"Case #{t+1}: {compute(N)}")