Under construction

Still being built. Things may change

Congestion Charging Zone

Interview

Time limit2sMemory limit512 MB

Summary
Given up to 100 camera sighting times for one vehicle, find its first and last times in 6:30 to 19:00 and output the matching charge from the table.
Level

Easy3 of 10

Topics
Implementation, Sorting
Solved
No attempts yet

Problem

The Tehran municipality has set up a new charging method for the Congestion Charging Zone (CCZ), which controls the passage of vehicles in Tehran's high-congestion areas during the congestion period (CP) from 6:30 to 19:00. There are plate detection cameras inside or at the entrances of the CCZ recording vehicles seen at the CCZ. The table below summarizes the new charging method.

The first time seen in the CPThe last time seen in the CPCharge
6:30 to 10:006:30 to 16:0024000
6:30 to 10:0016:01 to 19:0036000
10:01 to 16:0010:01 to 16:0016800
10:01 to 19:0016:01 to 19:0024000

Note that the first time and the last time that a vehicle is seen in the CP may be the same. Write a program to compute the amount of charge of a given vehicle in a specific day.

Input

The first line of the input contains a positive integer n (1 ≤ n ≤ 100) where n is the number of records for a vehicle. Each of the next n lines contains a time at which the vehicle is seen. Each time is of form <hour>:<minute>, where <hour> is an integer number between 0 and 23 (inclusive) and <minute> is formatted as an exactly two-digit number between 00 and 59 (inclusive).

Output

Print the charge to be paid by the owner of the vehicle in the output.

Examples3

  1. Example 1

    Input
    4
    7:30
    2:20
    7:30
    17:30
    
    Expected output
    36000
    
  2. Example 2

    Input
    1
    12:13
    
    Expected output
    16800
    
  3. Example 3

    Input
    2
    0:30
    23:30
    
    Expected output
    0