#K44057. Playlist Summary

    ID: 27446 Type: Default 1000ms 256MiB

Playlist Summary

Playlist Summary

You are given a playlist consisting of several songs. Each song is represented by two non-negative integers: the number of minutes and the number of seconds. Your task is to compute the total duration of the playlist and output it in one of the following formats:

  • If the total duration is exactly an integral number of hours (i.e. minutes and seconds are both zero), output 1 hour if it is 1 hour or X hours if it is more than one hour.
  • If there are no hours, but only seconds (i.e. minutes are zero), output Y seconds.
  • Otherwise, output the duration in the format H hours, M minutes, S seconds.

The following conversion formulas hold: $$1\text{ minute} = 60\text{ seconds}$$ and $$1\text{ hour} = 60\text{ minutes}$$.

If the playlist is empty, output 0 seconds.

inputFormat

The input is read from stdin and consists of:

  1. An integer N on the first line, representing the number of songs in the playlist.
  2. N subsequent lines, each containing two space-separated integers: the number of minutes and the number of seconds for that song.

outputFormat

Print to stdout a single line with the total duration of the playlist in the specified format.

## sample
4
4 35
3 50
2 45
5 20
0 hours, 16 minutes, 30 seconds