spoj#DOMINST. Dominant Strings
Dominant Strings
Dominant Strings
Given two strings s1 and s2, we say that s1 dominates s2 if the (multi)set of characters in s1 is a proper superset of the (multi)set of characters in s2. For instance, "acmicpc" dominates "camp", but it does not dominate "chimp" or "macpac". For a set S of strings, we call the strings in S which are not dominated by any string in S thedominant strings of S (even if they do not dominate any strings in S).
Now, your task is simply to find all the dominant strings of a set of strings.
Input
The input contains a single set of strings, with one string per line. Each string consists of at least one and at most ten lower-case alphabetic characters. There will be at most 15000 strings, and no two strings will be identical. Input is terminated by end-of-file.
Output
Output consists of all dominant strings in the input set, in alphabetical order, one word per line.
Example
Input:
acmicpc
cccp
macpac
chimp
camp
Output:
acmicpc
chimp
macpac