codeforces#P345F. Superstitions Inspection
Superstitions Inspection
Description
You read scientific research regarding popularity of most famous superstitions across various countries, and you want to analyze their data. More specifically, you want to know which superstitions are popular in most countries.
The data is given as a single file in the following format: country name on a separate line, followed by a list of superstitions popular in it, one entry per line. Each entry of the list is formatted as an asterisk "*" followed by a single space and then by the superstition name. Entries are unique within each country. The first line of input will represent a country. The input will contain at least one superstition.
Country name is a non-empty sequence of words, where each word consists of only English letters. The words of the name of some country will be separated in input with one or more spaces.
Superstition name is a non-empty sequence of words, where each word consists of only English letters and digits. The words of the name of some superstition will be separated in input with one or more spaces.
You can consider two names equal, if corresponding sequences of words are equal. You shouldn't consider the case of the letters when you compare the words.
Output the list of superstitions which are observed in the greatest number of countries. It's guaranteed that all countries have distinct names.
The input contains between 2 and 50 lines. Every line of input will contain between 1 and 50 characters, inclusive.
No line has leading or trailing spaces.
Output the list of superstitions which are observed in the greatest number of countries in alphabetical order. Each superstition must be converted to lowercase (one superstition can be written with varying capitalization in different countries).
The alphabetical order of superstitions means the lexicographical order of sequences of words (their names).
Input
The input contains between 2 and 50 lines. Every line of input will contain between 1 and 50 characters, inclusive.
No line has leading or trailing spaces.
Output
Output the list of superstitions which are observed in the greatest number of countries in alphabetical order. Each superstition must be converted to lowercase (one superstition can be written with varying capitalization in different countries).
The alphabetical order of superstitions means the lexicographical order of sequences of words (their names).
Samples
Ukraine
* Friday the 13th
* black cat
* knock the wood
USA
* wishing well
* friday the 13th
Holland
France
* Wishing Well
friday the 13th
wishing well
Spain
* Tuesday the 13th
Italy
* Friday the 17th
Russia
* Friday the 13th
England
* rabbit foot
friday the 13th
friday the 17th
rabbit foot
tuesday the 13th