{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":" \n \u003cp\u003eLara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father disappeared. In this mysterious island, Lara finds a tomb with a very heavy door. To open the door, Lara must input the password at the stone keyboard on the door. But what is the password? After reading the research notes written in her father\u0027s notebook, Lara finds out that the key is on the statue beside the door.\u003c/p\u003e \n \u003cp\u003eThe statue is wearing many arm rings on which some letters are carved. So there is a string on each ring. Because the letters are carved on a circle and the spaces between any adjacent letters are all equal, any letter can be the starting letter of the string. The longest common subsequence (let\u0027s call it \"LCS\") of the strings on all rings is the password. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\u003c/p\u003e \n \u003cp\u003eFor example, there are two strings on two arm rings: \u003cvar\u003es\u003csub\u003e1\u003c/sub\u003e\u003c/var\u003e \u003d \"abcdefg\" and \u003cvar\u003es\u003csub\u003e2\u003c/sub\u003e\u003c/var\u003e \u003d \"zaxcdkgb\". Then \"acdg\" is a LCS if you consider \u0027a\u0027 as the starting letter of \u003cvar\u003es\u003csub\u003e1\u003c/sub\u003e\u003c/var\u003e, and consider \u0027z\u0027 or \u0027a\u0027 as the starting letter of \u003cvar\u003es\u003csub\u003e2\u003c/sub\u003e\u003c/var\u003e. But if you consider \u0027d\u0027 as the starting letter of \u003cvar\u003es\u003csub\u003e1\u003c/sub\u003e\u003c/var\u003e and \u003cvar\u003es\u003csub\u003e2\u003c/sub\u003e\u003c/var\u003e, you can get \"dgac\" as a LCS. If there are more than one LCS, the password is the one which is the smallest in lexicographical order.\u003c/p\u003e \n \u003cp\u003ePlease find the password for Lara.\u003c/p\u003e \n "}},{"title":"Input","value":{"format":"HTML","content":" \n \u003cp\u003eThere are no more than 10 test cases.\u003c/p\u003e \n \u003cp\u003eIn each case:\u003c/p\u003e \n \u003cp\u003eThe first line is an integer \u003cvar\u003en\u003c/var\u003e, meaning there are \u003cvar\u003en\u003c/var\u003e (0 \u0026lt; \u003cvar\u003en\u003c/var\u003e ≤ 10) arm rings.\u003c/p\u003e \n \u003cp\u003eThen \u003cvar\u003en\u003c/var\u003e lines follow. Each line is a string on an arm ring consisting of only lowercase letters. The length of the string is no more than 8.\u003c/p\u003e \n "}},{"title":"Output","value":{"format":"HTML","content":" \n \u003cp\u003eFor each case, print the password. If there is no LCS, print 0 instead.\u003c/p\u003e \n \u003c/div\u003e \n "}},{"title":"Sample Input","value":{"format":"HTML","content":" \n \u003cpre\u003e2\r\nabcdefg\r\nzaxcdkgb\r\n5\r\nabcdef\r\nkedajceu\r\nadbac\r\nabcdef\r\nabcdafc\r\n2\r\nabc\r\ndef\u003c/pre\u003e \n "}},{"title":"Sample Output","value":{"format":"HTML","content":" \n \u003cpre\u003eacdg\r\nacd\r\n0\r\n\u003c/pre\u003e \n "}}]}