Time limit
2s
Memory limit
128 MB
Yeondoo is choosing a team name for a programming contest. Because she believes in superstition, she received a formula from Ihwan for calculating a team's chance of winning. She wants to use the formula to pick the candidate team name with the highest chance of winning.
The formula uses four variables: L, O, V, and E. Each variable is the number of times that letter appears after combining Yeondoo's English name with the team name.
L: the number of L characters in Yeondoo's English name and the team nameO: the number of O characters in Yeondoo's English name and the team nameV: the number of V characters in Yeondoo's English name and the team nameE: the number of E characters in Yeondoo's English name and the team nameSubstitute these four values into the following expression to get the winning chance for that team name.
((L + O) × (L + V) × (L + E) × (O + V) × (O + E) × (V + E)) mod 100
Given Yeondoo's English name and N candidate team names, output the team name with the highest winning chance. If several candidates have the same highest chance, choose the lexicographically smallest team name.
The first line contains Yeondoo's English name. The second line contains the number of candidate team names, N. Each of the next N lines contains one candidate team name.
Yeondoo's English name and every team name each have length between 1 and 20, inclusive, and consist only of uppercase English letters. N is a positive integer no greater than 50.
Print the team name with the highest winning chance on the first line.