Phone Bill

Time limit1sMemory limit128 MB

Problem

Phone rates depend on the time of day.

Each minute talked from 07:00 inclusive to 19:00 exclusive costs 10 won, and each minute talked from 19:00 inclusive to the next 07:00 exclusive costs 5 won.

Given the start time and duration of each call Sanggeun made, compute the total cost of all calls.

Input

The first line contains the number of calls N. (1 ≤ N ≤ 100)

Each of the next N lines contains one call in the format HH:MM DD.

HH:MM is the call start time, and DD is the call duration in minutes. DD is at most 60. There is exactly one space between MM and DD.

If the hour or minute has one digit, it is written with a leading zero.

Times range from 00:00 to 23:59.

Output

Print the total cost of all calls.