Problem
Young Hackers Club organized a forum on its website. The forum has the following structure: each post either starts a new topic or is a reply to some previous post and belongs to the same topic.
After several months of using their forum, the young hackers became interested in the question - what is the most popular topic on their forum. Help them figure it out.
Input
In the first line enter an integer N - the number of messages in the forum (1 <= N <= 1000). The following lines describe the messages in chronological order.
The description of the post, which is the start of a new topic, consists of three lines. The first line contains the number 0. The second line contains the topic name. The length of the name does not exceed 30 characters. The third line contains the text of the message.
A description of a post that is a response to another post consists of two lines. The first line contains an integer - the number of the message to which it is a response. Messages are numbered starting from one. The response always appears later than the message to which it is a response. The second line contains the text of the message.
The length of each message does not exceed 100 characters.
Output
Display the title of the topic with the largest number of posts. If there are several such topics, print the first one in chronological order
Input |
Output |
2
0
topic 1
body of message 1
0
topic 2
body of message 2
|
topic 1 |
Запрещенные операторы: sort