Speed Limit

For each log entry, multiply the speed by the time since the previous entry, sum these products, and print the total distance in miles.

Easy2ImplementationMathSimulationInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

Basri, Lim and Rama are taking a road trip during their semester break. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can record their speed and the total time they have driven. Unfortunately, their record keeping strategy is a little odd, so they need help computing the total distance driven. Write a program to do this computation.

For example, suppose their log shows

Speed (miles/hour)Total elapsed time in hours
202
306
107

This means they drove 2 hours at 20 miles per hour, then 62=46-2=4 hours at 30 miles per hour, then 76=17-6=1 hour at 10 miles per hour. The distance driven is then (2)(20)+(4)(30)+(1)(10)=40+120+10=170(2)(20)+(4)(30)+(1)(10)=40+120+10=170 miles. Note that the total elapsed time is always measured from the beginning of the trip, not from the previous entry in the log.

Input

The input consists of one or more data sets. Each set starts with a line containing an integer nn (1n101 \le n \le 10), followed by nn pairs of values, one pair per line. The first value in a pair, ss, is the speed in miles per hour, and the second value, tt, is the total elapsed time. Both ss and tt are integers with 1s901 \le s \le 90 and 1t121 \le t \le 12. The values of tt are always in strictly increasing order. A value of 1-1 for nn signals the end of the input.

Output

For each data set, print the distance driven, followed by a space, followed by the word "miles".