Guess the Algorithms That Will Appear at KCPC
Time limit1sMemory limit1024 MB
Given N problems, each with a list of tags, print the tag that appears on the most problems, or -1 if several tags tie for the top count.
Problem
You are taking part in KCPC and want to use big data to predict which algorithms will appear in this contest.
Given each problem number, the number of tags attached to it, and the list of tags, print the tag that appears most often.
Input
The first line contains the number of problems ().
From the second line onward, lines give the information for each problem in the following format.
-
- is an integer for the problem number ().
- is an integer for the number of tags on the problem ().
- is a tag of problem , a string of lowercase English letters and
_(). - The tags on each problem are all distinct.
The problems are given in increasing order of , and all problem numbers are different.
Output
Print the most frequently appearing tag on the first line. If several tags tie for the most appearances, print -1.
Hint
The test data may not match real online judge problems or solved.ac tags.