#K2716. Longest Common Suffix

    ID: 24799 Type: Default 1000ms 256MiB

Longest Common Suffix

Longest Common Suffix

Given a list of strings, find the longest common suffix among them. A suffix is defined as the ending part of a string. For example, if the input words are running, jogging, and walking, the longest common suffix is ing.

If there is no common suffix, output an empty string.

Note: The input will first contain an integer n representing the number of words, followed by n lines, each containing a word.

inputFormat

The first line of input contains a single integer n (0 ≤ n ≤ 105) representing the number of words. The following n lines each contain a non-empty string consisting of lowercase and/or uppercase letters.

If n is 0, then there are no words and the output should be an empty string.

outputFormat

Output a single line containing the longest common suffix of all the given words. If no common suffix exists, output an empty string.

## sample
3
running
jogging
walking
ing

</p>