{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eRJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure 1.\u003c/p\u003e\u003cp align\u003d\"center\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/bd3455a60857b83f9af92a86906c5aae?v\u003d1714401443\" border\u003d\"1\"\u003e\u003cbr\u003eFigure 1: Layout of the exchange lines\u003c/p\u003e\u003cp\u003eA freight train consists of 2 to 72 freight cars. There are 26 types of freight cars, which are denoted by 26 lowercase letters from \"a\" to \"z\". The cars of the same type are indistinguishable from each other, and each car\u0027s direction doesn\u0027t matter either. Thus, a string of lowercase letters of length 2 to 72 is sufficient to completely express the configuration of a train.\u003c/p\u003e\u003cp\u003eUpon arrival at the exchange lines, a train is divided into two sub-trains at an arbitrary position (prior to entering the storage lines). Each of the sub-trains may have its direction reversed (using the reversal line). Finally, the two sub-trains are connected in either order to form the final configuration. Note that the reversal operation is optional for each of the sub-trains.\u003c/p\u003e\u003cp\u003eFor example, if the arrival configuration is \"abcd\", the train is split into two sub-trains of either 3:1, 2:2 or 1:3 cars. For each of the splitting, possible final configurations are as follows (\"+\" indicates final concatenation position):\u003c/p\u003e\u003cpre\u003e [3:1]\u003cbr\u003e abc+d cba+d d+abc d+cba\u003cbr\u003e [2:2]\u003cbr\u003e ab+cd ab+dc ba+cd ba+dc cd+ab cd+ba dc+ab dc+ba\u003cbr\u003e [1:3]\u003cbr\u003e a+bcd a+dcb bcd+a dcb+a\u003c/pre\u003e\u003cp\u003eExcluding duplicates, 12 distinct configurations are possible.\u003c/p\u003e\u003cp\u003eGiven an arrival configuration, answer the number of distinct configurations which can be constructed using the exchange lines described above.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe entire input looks like the following.\u003c/p\u003e\u003cblockquote\u003e\u003cp\u003e\u003ci\u003ethe number of datasets \u003d m\u003c/i\u003e\u003cbr\u003e\u003ci\u003e1st dataset\u003c/i\u003e \u003cbr\u003e\u003ci\u003e2nd dataset\u003c/i\u003e \u003cbr\u003e... \u003cbr\u003e\u003ci\u003em-th dataset\u003c/i\u003e\u003c/p\u003e\u003c/blockquote\u003e\u003cp\u003eEach dataset represents an arriving train, and is a string of 2 to 72 lowercase letters in an input line.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each dataset, output the number of possible train configurations in a line. No other characters should appear in the output.\u003c/p\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\u003e4\r\naa\r\nabba\r\nabcd\r\nabcde\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n6\r\n12\r\n18\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}