Under construction

Still being built. Things may change

Guess the Algorithms That Will Appear at KCPC

Time limit1sMemory limit1024 MB

Summary
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.
Level

Easy3 of 10

Topics
Hash map, String
Solved
No attempts yet

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 NN (1≤N≤10001 \leq N \leq 1000).

From the second line onward, NN lines give the information for each problem in the following format.

  • ss tt a1a_1 a2a_2 ⋯\cdots ata_t

    • ss is an integer for the problem number (1000≤s≤321961000 \leq s \leq 32196).
    • tt is an integer for the number of tags on the problem (1≤t≤1001 \leq t \leq 100).
    • aia_i is a tag of problem ss, a string of lowercase English letters and _ (1≤∣ai∣≤311 \leq |a_i| \leq 31).
    • The tt tags on each problem are all distinct.

The problems are given in increasing order of ss, and all NN 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.

Examples2

  1. Example 1

    Input
    6
    30701 2 greedy sorting
    30702 4 bfs dfs graphs graph_traversal
    30705 2 data_structures disjoint_set
    30706 2 geometry math
    30707 4 constructive graphs greedy mst
    30708 3 ad_hoc constructive greedy
    
    Expected output
    greedy
    
  2. Example 2

    Input
    6
    30701 2 greedy sorting
    30702 4 bfs dfs graphs graph_traversal
    30705 2 data_structures disjoint_set
    30706 2 geometry math
    30707 4 constructive graphs greedy mst
    30708 2 ad_hoc constructive
    
    Expected output
    -1