{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us. \r\u003cbr\u003e\r\u003cbr\u003eThere is a large number of magnetic plates on every door. Every plate has one word written on it. The plates must be arranged into a sequence in such a way that every word begins with the same letter as the previous word ends. For example, the word ``acm\u0027\u0027 can be followed by the word ``motorola\u0027\u0027. Your task is to write a computer program that will read the list of words and determine whether it is possible to arrange all of the plates in a sequence (according to the given rule) and consequently to open the door. \r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing a single integer number Nthat indicates the number of plates (1 \u0026lt;\u003d N \u0026lt;\u003d 100000). Then exactly Nlines follow, each containing a single word. Each word contains at least two and at most 1000 lowercase characters, that means only letters \u0027a\u0027 through \u0027z\u0027 will appear in the word. The same word may appear several times in the list. "}},{"title":"Output","value":{"format":"HTML","content":"Your program has to determine whether it is possible to arrange all the plates in a sequence such that the first letter of each word is equal to the last letter of the previous word. All the plates from the list must be used, each exactly once. The words mentioned several times must be used that number of times. \r\u003cbr\u003eIf there exists such an ordering of plates, your program should print the sentence \"Ordering is possible.\". Otherwise, output the sentence \"The door cannot be opened.\". \r\u003cbr\u003e"}},{"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\u003e3\r\n2\r\nacm\r\nibm\r\n3\r\nacm\r\nmalform\r\nmouse\r\n2\r\nok\r\nok\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eThe door cannot be opened.\r\nOrdering is possible.\r\nThe door cannot be opened.\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}