Problem 1934. -- [Usaco2009 Open]Time Cards## 1934: [Usaco2009 Open]Time Cards

Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 0 Solved: 0

[Submit][Status][Web Board]## Description

Farmer John wanted to improve farm productivity, so his cows nowget extra hay if they spend more tim

e at a milking machine. Toimplement this plan, he has instituted the use of time cards foreach of th

e N (1 <= N <= 145) cows conveniently numbered 1..N. Whena cow starts at a milking machine, she ente

rs the start time on themaster time card. Likewise, when she leaves, she notes that on themaster tim

e card, as well. FJ is fortunate to have enough milkingmachines that he can milk every cow at the sa

me time.The time entries are typed into a computer file where each lineincludes a cow number C (1 <=

C <= N), a keyword ('START' or 'STOP'),and the time expressed as two space-separated integers HH an

d MM(0 <= HH <= 23; 0 <= MM <= 59). Cows never stay at the machine pastmidnight. The timecard file i

s complete in the sense that everycow's START entry contains a corresponding STOP entry later in the

input file.Calculate the total time each cow spends at the milking machine.By way of example, consid

er a time card file for just two cows. Thefile includes not only the number of cows but also the tot

al numberof time card entries, Nlines (1 <= Nlines <= 1,458).

2 6

1 START 9 0

2 START 9 30

1 STOP 10 0

2 STOP 10 15

1 START 17 0

1 STOP 17 42

Cow 1 spent times 9:00-10:00 and 17:00-17:42 at the machine for atotal of one hour and 42 minutes (1

:42). Cow 2 spent time 9:30-10:15at the machine, for a total of 45 minutes.

## Input

* Line 1: Two space-separated integers: N and Nlines

* Lines 2..Nlines+1: Each line contains four space-separated entities:

C, keyword, HH, and MM

## Output

* Lines 1..N: Line i contains two space-separated integers that are

respectively the number of hours and minutes that cow i spends

at the milking machine. Of course, the minutes value never

exceeds 59.

## Sample Input

2 6
1 START 9 0
2 START 9 30
1 STOP 10 0
2 STOP 10 15
1 START 17 0
1 STOP 17 42

## Sample Output

1 42
0 45

## HINT

## Source

[Submit][Status]