Under construction

Still being built. Things may change

Phone Bill

Interview

Time limit1sMemory limit128 MB

Summary
Given N calls with a start time and duration under 60 minutes, sum the cost by charging 10 won per minute in 07:00-19:00 and 5 won otherwise, splitting calls that cross the boundary.
Level

Easy3 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

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.

Examples3

  1. Example 1

    Input
    2
    11:02 11
    15:30 01
    
    Expected output
    120
    
  2. Example 2

    Input
    3
    20:05 12
    06:45 30
    13:08 15
    
    Expected output
    435
    
  3. Example 3

    Input
    5
    00:00 05
    06:47 35
    11:30 18
    18:33 60
    23:59 22
    
    Expected output
    1035