In a new debate among a group of N individuals, they've met a different criterion. If two individuals express sentences of equal value, precedence will be given to the elder among them, as age often signifies more life experience.
The value of a sentence remains the same as in the previous problem, whoever mentioned the the keyword the most in their sentences would be considered the most valuable. However, when individuals presented sentences of equal value, the deciding factor became the order of their age, if they're also in the same age, it would become the order in which they spoke.
Hint:
/* strtok example */
#include <stdio.h>#include <string.h> int main () { char str[] ="- This, a sample string."; char * pch; printf ("Splitting string \"%s\" into tokens:\n",str); pch = strtok (str," ,.-"); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, " ,.-"); } return 0; }
Output:
Splitting string "- This, a sample string." into tokens: This a sample string
The first line contains an integer N and a keyword.
Each of the next N lines represents a person in the following format:
the concatenation of "Name:<name>", "Age:<age>" and "Sentence:<sentence>", separated by semicolon ';'
where <name>, <age>, <sentence> represent a person's name, age, and the sentence he delivered, respectively.
Notice that name, age, and sentence may not appear in order.
len(keyword) <= 1000, N <= 1000, length of each line <= 100000
keyword is only composed by english letters.
<name> is composed by english letters and spaces.
<age> is an integer between [1, 100].
<sentence> is composed by english letters, spaces, and ",.?!" these four punctuation marks.
For testcase 1, 2: <name>, <age>, and <sentence> would appear in order, length of <name> would be 100, length of <age> would be 2, and length of <sentence> would be 10000
For testcase 3, 4: <name>, <age>, and <sentence> would appear in order
For testcase 5, 6: length of <name> would be 100, length of <age> would be 2, and length of <sentence> would be 10000
For testcase 7, 8: no other restriction
If the k-th person delivered the most valuable sentence, please output like this:
<namek>: <sentencek>
There is a space after ':' and a '\n' in the end.