# Arup Guha
# 7/16/2013
# Solution to Sample Contest Problem: Car

def main():

    # Open the input file.
    myFile = open("car.in", "r")

    numCases = int(myFile.readline())

    # Go through each case.
    for loop in range(1, numCases+1):

        # Initialize our accumulator variables.
        totalD = 0
        totalH = 0

        numSpeeds = int(myFile.readline())

        # Read through each distinct driving segment.
        for i in range(numSpeeds):

            # Extract both values on this line.
            values = myFile.readline().split()
            hours = int(values[1])/60
            speed = float(values[0])

            # Update time and distance driven
            totalH = totalH + hours
            totalD = totalD + speed*hours

        # Print answer for this case, by dividing totals.
        avg = totalD/totalH
        print("Car #",loop,": On average this car went at ", avg, " mph.", sep="")

    # Close the input file.
    myFile.close()

main()
