public static void main(String[] args) {
		long start = System.currentTimeMillis();
		try {
			FileReader fr = new FileReader(SourcePath.getInputPath() + "/googleCodeJam/round1A2010/C-large-practice.in");
			FileWriter fw = new FileWriter(SourcePath.getOutputPath() + "/googleCodeJam/round1A2010/C-large-practice.out");

			BufferedReader br = new BufferedReader(fr);
			BufferedWriter bw = new BufferedWriter(fw);
			int numOfCases = Integer.valueOf(br.readLine());
			
			StringBuffer outPut = new StringBuffer();
			
			int positionAStart;
			int positionAEnd;
			int positionBStart;
			int positionBEnd;
			
			String[] positions;
			long result;
			for (int i = 0; i < numOfCases; i++){
				positions = br.readLine().split(" ");
				
				positionAStart = Integer.valueOf(positions[0]);
				positionAEnd = Integer.valueOf(positions[1]);
				positionBStart = Integer.valueOf(positions[2]);
				positionBEnd = Integer.valueOf(positions[3]);
				
				result = getWinningPositionNum(positionAStart, positionAEnd, positionBStart, positionBEnd);
				
				System.out.println("Case #" + (i + 1) + ": " + result);
				outPut.append("Case #").append(i+1).append(": ").append(result).append("\n");
			}
			
			br.close();
			fr.close();
			bw.write(outPut.toString());
			bw.flush();
			bw.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		long end = System.currentTimeMillis();
		
		System.out.println(end - start);
	}