import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

import javax.swing.JFileChooser;

public class codeJam3 {
	
	private static long[][] results = new long[1000][1000];
	private static int count = 0;
	
	public static void main(String[] args) throws IOException {
		long result = 0;
		
		//Test Code
		/*for(int i = 500; i < 600; i++) {
			for(int j = 4; j <= 4; j++) {
				count = 0;
				result = FTest(i,j);
				System.out.println("(" + i + "," + j + "): " + count + " : " + result);
			}
		}*/
		
		//Set up IO
		Scanner s = null;
		s = new Scanner(getFile());
		Writer output = null;
		File file = new File("eggs.out");
		output = new BufferedWriter(new FileWriter(file));
		
		//Solve and Output
		int numCases = s.nextInt();
		s.nextLine();
		long F, D, B;
		long Fmax, Dmin, Bmin;
		for(int i = 0; i < numCases; i++) {
			output.write("Case #" + (i+1) + ": ");
			F = s.nextLong();		
			D = s.nextLong();
			B = s.nextLong();
			Fmax = FTest(D,B);
			Dmin = DTest(F,B);
			Bmin = BTest(F,D);
			
			System.out.println(F + " " + D + " " + B + " : " + Fmax + " " + Dmin + " " + Bmin);
			output.write(Fmax + " ");
			output.write(Dmin + " ");
			output.write(Bmin + "\n");
			
		}
		output.close();
		
	}
	
	//Finds the maximum number of floors for a given number or eggs and breakable eggs.
	//Recursive Solution
	private static long FTest(long D, long B) {
		
		//Test Var
		count++;
	
		//See if solution has already been found. If so, we're done.
		if(D < results.length && B < results.length && results[(int)D][(int)B] != 0)
			return results[(int)D][(int)B];
				
		//Vars
		long result = 1;
		long result2 = 1;
		long result3 = 1;
		
		//If there is only 1 breakable egg, we can only check D more floors (from the bottom up).
		//If there is only one more egg, we can only check one more floor.
		if(B == 1 || D == 1)
			result = D;
		//If there are 2 more breakable eggs, this is the formula.
		else if(B == 2) {
			return D*(D+1)/2;
		}
		//If there are 3,
		else if(B == 3) {
			//After a certain D, it doesn't matter, we have overflow.
			if(D > 2953)
				return -1;
			//Otherwise the formula is a series of the 2 formula.
			result = 0;
			for(int i = 1; i < D; i++)
				result += i*(i+1)/2;
			return D + result;
		}
		//If we have 4 or higher, at a certain D we always have overflow.
		else if(B > 3 && D > 567)
			return -1;
		//If B is greater than D, we don't care about B -- the solution is just 2^D-1
		else if(B >= D)
			result = (long) (Math.pow(2, D) - 1);
		else {
			//Recursive Solution for all other cases. Assume we check a floor. Now we have D-1 eggs.
			//If the egg broke, we have B-1 eggs and should check below this floor.
			//If the egg didn't break, we have B eggs and should check the floor above this floor.
			result2 = 1 + FTest(D-1,B);
			result3 = FTest(D-1,B-1);
			
			//Check for overflow at any point in calculation
			if(result2 > Math.pow(2, 32) || result2 <= 0) {
				if(D < results.length && B < results.length)
					results[(int)D][(int)B] = -1;
				return -1;
			}
			if(result3 > Math.pow(2, 32) || result3 <= 0) {
				if(D < results.length && B < results.length)
					results[(int)D][(int)B] = -1;
				return -1;
			}
			
			//Solution
			result = 1 + FTest(D-1,B) + FTest(D-1,B-1);
		}
		
		
		//Check for overflow
		if(result > Math.pow(2, 32) || result <= 0)
			result = -1;
		
		//Store solution (if it will fit in array) so we never have to solve for it again.
		if(D < results.length && B < results.length)
			results[(int)D][(int)B] = result;
		
		return result;
	}
	
	//Test for minimum number of eggs given number of floors and number of breakable eggs.
	private static int DTest(long F, long B) {
		//Hehehe cheat -- just run values through FTest until we reach F. 
		for(int i = 1; i < 10000; i++)
			if(FTest(i,B) >= F || FTest(i,B) == -1)
				return i;
		return -1;
	}
	
	//Test for minimum number of breakable eggs given number of floors and number of eggs.
	private static int BTest(long F, long D) {
		//Hehehe cheat -- just run values through FTest until we reach F. 
		for(int i = 1; i < 10000; i++)
			if(FTest(D, i) >= F || FTest(D,i) == -1)
				return i;
		return -1;
	}
	
	
	public static File getFile(){
        // create a GUI window to pick the text to evaluate
        JFileChooser chooser = new JFileChooser(".");
        int retval = chooser.showOpenDialog(null);
        File f = null;
        chooser.grabFocus();
        if (retval == JFileChooser.APPROVE_OPTION)
           f = chooser.getSelectedFile();
        return f;
    }
	
}
