{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003ch3\u003e Read problems statements in \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/COOK63/mandarin/PP.pdf\"\u003eMandarin Chinese\u003c/a\u003e and \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/COOK63/russian/PP.pdf\"\u003eRussian\u003c/a\u003e as well.\u003c/h3\u003e\n\n\n\u003cp\u003e\nGiven a list of strings \u003cb\u003eS\u003c/b\u003e[ 1..\u003cb\u003eN\u003c/b\u003e ], you need to count how many ordered pairs of strings are awesome. Given two integers i and j, such that 1 ≤ i, j ≤ n and i ≠ j, an ordered pair ( \u003cb\u003eS\u003c/b\u003e[ \u003cb\u003ei\u003c/b\u003e ], \u003cb\u003eS\u003c/b\u003e[ \u003cb\u003ej\u003c/b\u003e ] ) is called awesome if and only if concatenating \u003cb\u003eS\u003c/b\u003e[ \u003cb\u003ei\u003c/b\u003e ] and \u003cb\u003eS\u003c/b\u003e[ \u003cb\u003ej\u003c/b\u003e ] gives a palindrome.\u003c/p\u003e\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eThe first line contains an integer \u003cb\u003eT\u003c/b\u003e denoting the total number of test cases.\u003c/p\u003e\n\u003cp\u003eIn each test case, the first line contains an integer \u003cb\u003eN\u003c/b\u003e denoting the total number of strings.\u003c/p\u003e\n\u003cp\u003eThen, there are \u003cb\u003eN\u003c/b\u003e strings, each in a separate line. They only consist of lower case characters.\u003c/p\u003e\n\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eFor each test case, output a single line containing the answer.\u003c/p\u003e\n\n\u003ch3\u003eConstraints\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e \u003c\u003d \u003cb\u003eT\u003c/b\u003e \u003c\u003d \u003cb\u003e5\u003c/b\u003e\u003c/li\u003e\nIn each test case,\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e \u003c\u003d \u003cb\u003eN\u003c/b\u003e \u003c\u003d \u003cb\u003e10^6\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003eSum of lengths of \u003cb\u003eN\u003c/b\u003e strings \u003c\u003d \u003cb\u003e10^6\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\u003e1\n3\na\nab\nabb\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eab|a and abb|a\u003c/p\u003e"}}]}