#C11661. Common Characters Among Gemstones

    ID: 41002 Type: Default 1000ms 256MiB

Common Characters Among Gemstones

Common Characters Among Gemstones

You are given several test cases. In each test case, you are provided with n strings representing gemstones. Your task is to identify all the characters that appear in every one of the gemstones, and then print these common characters in sorted (alphabetical) order. If there are no characters common to all gemstones in a test case, you should output No common characters.

Formally, let \(G = [g_1, g_2, \dots, g_n]\) be the list of gemstone strings and let each \(g_i\) be composed of characters. You are to compute:

[ C = \bigcap_{i=1}^{n} { c \mid c \in g_i } ]

If \(C \neq \emptyset\), output the characters in \(C\) sorted in increasing order. Otherwise, output "No common characters".

inputFormat

The input consists of several test cases. Each test case begins with an integer n (\(n \ge 1\)) representing the number of gemstone strings. This is followed by n lines, each containing one gemstone string. The input terminates with a test case where n is 0, which should not be processed.

outputFormat

For each test case, output a single line. This line should contain the sorted common characters if at least one exists, or the string "No common characters" if there are none.

## sample
3
abcdde
baccd
eeabg
2
xyz
xyt
0
ab

xy

</p>