
Back cover of Last Christmas, modified. Public Domain by Epic Records / CBS Records Inc.
A Christmas market is incomplete without live music, and you will find everything from out-of-tune renditions of "Jingle Bells" on a toy xylophone to professional arrangements of Bach's Christmas Oratorio. This year, Jonathan and Merle also want to earn some money playing Christmas songs, but they cannot even agree on which artists, let alone which songs. Jonathan likes Mariah Carey best, while Merle loves the whole Christmas album by the Goo Goo Dolls.
They decide to settle the discussion using statistics and the following strategy. They take $$$n$$$ past Christmas top-10 lists and count how often each artist appears. Note that an artist may appear multiple times on the same list. The artist with the highest number of appearances is clearly the best! If there is a tie, they look at the artist with the highest number of number 1 hits among the artists with the highest number of appearances. If there is still a tie, they look at highest number of number 2 hits among those, and so on.
Who is the best artist for the Christmas season?
The input consists of:
$$$^{\text{∗}}$$$If Madonna does not need a last name, why would other artists need one?
Output the name of the best artist according to the rules described above, or "tie" if there is no unique best artist.
3elton jose bowie eagles elvis wham nat joni bruce minnieelton madonna wham elvis andy donny madonna aha chuck judymadonna heart whitney chuck joni wham john yoko nsync stevie
madonna
3maria a b wham c d e f maria whamwham g h maria i j k l wham mn o p q r s t u v maria
tie
2b a b d e a e a b ab b b e d a d a a a
a
In the first sample test, Madonna and Wham! both appear three times in total, but since Madonna has one more number 1 hit than Wham!, Madonna is the best artist.