Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Match the Substring

By subhashis_cse · Limits 1s, 512 MB

String Matching is an important problem in computer science research and finds applications in data mining, pattern recognition, and many more areas.

The problem we consider here is a smaller version of it. You are given a set of strings. You have to find a string which all given strings are the substring of it.

A substring is a contiguous sequence of characters within a string. Such as “love” is a substring of “I love you”.

In here there are no common characters between any two strings. And you should print the string so that substring of all given strings are a consecutive sequence.

Try to print the string so that the length is as minimum as possible.

Input

In the first line there is an integer N (1 ≤ N ≤ 25) which is the number of strings and the following N lines are the strings. The only characters that will occur are lowercase characters of English alphabet (‘a’-‘z’). String lengths will be less or equal to 26.

Output

Just print the string in a line.

Sample

InputOutput
2
a
b
ab

Discussion

Statistics


96% Solution Ratio

wajiulEarliest, 3w ago

wajiulFastest, 0.0s

wajiulLightest, 0 B

mdvirusShortest, 51B

Submit

Login to submit

Related Contests

5th CPU CSE Programming Contest Ended at 2020-03-16 09:00:00 +0000 UTC