/* 
 * Solution by Christian Kauth - September 2009 - Solves all testcases at
 * http://acm.uva.es/archive/nuevoportal/data/problem.php?p=4445
 * Try all 8! = 40'320 orders of the planes to land. For each ordering, 
 * the largest possible idle window can be found by binary search and
 * by greedily checking whether a given window duration can be achieved. 
 * Attention : The landing time of an airplane may be an non-integral
 *             number of seconds.
 */

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

#define MAX		 8
#define IDLE	-1
#define LATEST	86400.1
#define TOL		0.1

double start[MAX], stop[MAX];
int p[MAX];
int N, id;
double maxSpan;

bool read_case()
{
	cin>>N;
	if (N==0)
		return false;
	for (int i=0; i<N; i++)
	{
		cin>>start[i]>>stop[i];
		start[i] *= 60.0;
		stop[i]  *= 60.0;
		p[i] = IDLE;
	}
	id = IDLE;
	maxSpan = IDLE;
	return true;
}

bool greedy_place(double x)
{
	double t(start[p[0]]);
	for (int i=1; i<N; i++)
	{
		if (stop[p[i]] < t+x)
			return false;
		t = max(t+x,start[p[i]]);
	}
	return true;
}

void binary_search()
{
	double x, l(0.0), r(LATEST);
	bool feasible;

	do
	{
		x = (l+r)/2.0;
		greedy_place(x) ? l = x : r = x; 
		if (r<maxSpan) return;
	} while (r > l+TOL);

	if (x > maxSpan)
		maxSpan = x;
}

void perm(int k)
{
	p[k] = ++id;
	if (id == (N-1))
		binary_search();
	else
		for (int t=0; t<N; t++)
			if (p[t] == IDLE)
				perm(t);
	p[k] = IDLE;
	id--;
}

int main()
{
	int nCase(1);
	int inter;

	while (read_case())
	{
		for (int i=0; i<N; i++)
			perm(i);
		inter = (int)(floor(maxSpan+0.5));
		cout<<"Case "<<nCase<<": "<<inter/60<<":";
		inter %= 60;
		cout<<inter/10<<inter%10<<endl;
		nCase++;
	}
	return 0;
}
