{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"A 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\u003cbr\u003e\u003cpre\u003edog.gopher\r\u003cbr\u003egopher.rat\r\u003cbr\u003erat.tiger\r\u003cbr\u003ealoha.aloha\r\u003cbr\u003earachnid.dog\u003c/pre\u003e\r\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\u003cbr\u003e\r\u003cbr\u003ealoha.aloha.arachnid.dog.gopher.rat.tiger\r\u003cbr\u003e\r\u003cbr\u003eGiven a dictionary of lower case words, you are to find a compound catenym that contains each of the words exactly once."}},{"title":"Input","value":{"format":"HTML","content":"The first line of standard input contains t, the number of test cases. Each test case begins with 3 \u0026lt;\u003d n \u0026lt;\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."}},{"title":"Output","value":{"format":"HTML","content":"For 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. "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\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\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003ealoha.arachnid.dog.gopher.rat.tiger\r\n***\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}