Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
北京大学《ACM-ICPC竞赛训练》暑期课面向全球招生。容量有限,报名从速!
Language:
Funny Language
Time Limit: 5000MSMemory Limit: 65536K
Total Submissions: 307Accepted: 94Special Judge

Description

There is a well know game with words. Given a word you have to write as many other words as possible using the letters from the given word. If the letter repeats multiple times in the original word, you can use it up to as many times in the new words. The order of letters in the original word does not matter. For example, given the word CONTEST you can write NOTE, NET, ON, TEST, SET, etc.
Now you are in charge of writing a new dictionary. Your task is to sneak n new words into it. You know in advance m words Wi (1 <= i <= m) that you will have to play a game with and you need to figure out which new n words to add to the dictionary to maximize the total number of words you can write out of these m words.
More formally, find such a set of nonempty words S where |S| = n, Wi \notin S for any i, and \sum\limits_{i = 1}^m {|S_i|} is maximal, where Si \subset S is the set of words that can be written using letters from Wi.

Input

The first line of the input file contains two integer numbers n (1 <= n <= 100) - the number of new words you can add to the dictionary and m (1 <= m <= 1 000) - the number of words you will play the game with. The following m lines contain original words. Each word consists of at most 100 uppercase letters from A to Z.

Output

Write to the output file n lines with a new word on a line.

Sample Input

3 5
A
ACM
ICPC
CONTEST
NEERC

Sample Output

C
CN
E

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator