// Danny Wasserman
// 7/14/2011
// Solution for BHCSI 2011 Practice Contest #1 Problem: Car

import java.util.*;
import java.io.*;

public class car
{
	public static void main(String[] args) throws IOException
	{
		// Open the input file.
		Scanner in = new Scanner(new File("car.in"));
		int cases = in.nextInt();
		
		// Go through each input case.
		for(int c = 1; c <= cases; c++)
		{
			
			// Get the data for this case.
			int datas = in.nextInt();
			double milesTotal = 0;
			int minutesTotal = 0;
			
			// Add up the total miles traveled and minutes traveled.
			for(int i = 0; i < datas; i++)
			{
				double nextSpeed = in.nextDouble();
				int nextMinutes = in.nextInt();
				minutesTotal+=nextMinutes;
				milesTotal+=nextSpeed * (nextMinutes / 60.0);
			}
			
			// Calculate and output the average.
			double hoursTotal = (minutesTotal/60.0);
			System.out.println("Car #"+c+": On average this car went at "+(milesTotal/hoursTotal)+" mph.");
		}
		
	}
}