{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eA catenym is a pair of words separated by a period such that the last letter of the first word is the same as the last letter of the second. For example, the following are catenyms: \r\n\u003cbr\u003e\u003cpre\u003edog.gopher\r\n\u003cbr\u003egopher.rat\r\n\u003cbr\u003erat.tiger\r\n\u003cbr\u003ealoha.aloha\r\n\u003cbr\u003earachnid.dog\u003c/pre\u003e\r\n\u003cbr\u003eA compound catenym is a sequence of three or more words separated by periods such that each adjacent pair of words forms a catenym. For example, \r\n\u003cbr\u003e\r\n\u003cbr\u003ealoha.aloha.arachnid.dog.gopher.rat.tiger\r\n\u003cbr\u003e\r\n\u003cbr\u003eGiven a dictionary of lower case words, you are to find a compound catenym that contains each of the words exactly once.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eThe first line of standard input contains t, the number of test cases. Each test case begins with 3 \u003c\u003d n \u003c\u003d 1000 - the number of words in the dictionary. n distinct dictionary words follow; each word is a string of between 1 and 20 lowercase letters on a line by itself.\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eFor each test case, output a line giving the lexicographically least compound catenym that contains each dictionary word exactly once. Output \"***\" if there is no solution. \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2\r\n6\r\naloha\r\narachnid\r\ndog\r\ngopher\r\nrat\r\ntiger\r\n3\r\noak\r\nmaple\r\nelm\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003ealoha.arachnid.dog.gopher.rat.tiger\r\n***\r\n\u003c/pre\u003e"}}]}