Election

Time limit1sMemory limit128 MB

Problem

Canada has a multi-party system of government. Each candidate is generally associated with a party, and the party whose candidates win the most ridings generally forms the government. Some candidates run as independents, meaning they are not associated with any party. Your job is to count the votes for a particular riding and to determine the party with which the winning candidate is associated.

Input

The first line contains a positive integer $n$ ($2 \le n \le 20$), the number of candidates in the riding.

Then $n$ pairs of lines follow. In each pair, the first line is the name of the candidate (up to 80 characters), and the second line is the name of the party (up to 80 characters), or the word independent if the candidate has no party. No candidate name is repeated and no party name is repeated. No line contains leading or trailing blanks.

The next line contains a positive integer $m$ ($m \le 10000$), followed by $m$ lines, each giving the name of a candidate for which a ballot is cast. Any name not in the list of candidates is ignored.

Output

Output a single line containing one of the following:

  • The name of the party with which the winning candidate is associated, if there is a winning candidate and that candidate belongs to a party.
  • The word independent if there is a winning candidate and that candidate has no party.
  • The word tie if there is no winner; that is, if no candidate receives more votes than every other candidate.