#K35512. Construct Unique Playlists

    ID: 25548 Type: Default 1000ms 256MiB

Construct Unique Playlists

Construct Unique Playlists

You are given information about one or more users. For each user, you are provided with several music genres they have rated. For each genre, a list of songs along with their ratings is given. Your task is to construct a unique playlist for each user by selecting the song with the highest rating in each genre.

The input starts with an integer \(T\) representing the number of users. For each user, the first line contains an integer \(G\), the number of genres for that user. This is followed by \(G\) lines, each containing the information for one genre in the following format:

genre_name \(\;K\;) song1 rating1 song2 rating2 ... songK ratingK

Note that if two or more songs have the same rating within a genre, choose the one that appears first.

The output for each user should list the selected songs in the same order as input, each in the format:

Genre: Song (Rating)

If there are multiple users, separate their outputs with an empty line.

inputFormat

The input is read from stdin and has the following format:

  1. An integer \(T\) representing the number of users.
  2. For each user:
    1. An integer \(G\) representing the number of genres.
    2. Then \(G\) lines follow, each describing a genre in the format:
      genre_name K song1 rating1 song2 rating2 ... songK ratingK

All inputs are provided via stdin.

outputFormat

The output should be printed to stdout and for each user should contain \(G\) lines in the following format:

Genre: Song (Rating)

If there are multiple users, separate each user's output by an empty line.

## sample
2
2
Rock 3 HotelCalifornia 85 StairwayToHeaven 95 BohemianRhapsody 90
Pop 2 BlindingLights 88 Levitating 80
3
Jazz 2 SoWhat 75 TakeFive 80
Classical 1 FurElise 93
HipHop 1 SickoMode 78
Rock: StairwayToHeaven (95)

Pop: BlindingLights (88)

Jazz: TakeFive (80) Classical: FurElise (93) HipHop: SickoMode (78)

</p>