{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eJimmy invents an interesting card game. There are N cards, each of which contains a string Si. Jimmy wants to stick them into several circles, and each card belongs to one circle exactly. When sticking two cards, Jimmy will get a score. The score of sticking two cards is the longest common prefix of the second card and the reverse of the first card. For example, if Jimmy sticks the card S1 containing \"abcd\" in front of the card S2 containing \"dcab\", the score is 2. And if Jimmy sticks S2 in front of S1, the score is 0. The card can also stick to itself to form a self-circle, whose score is 0.\u003cbr\u003e\u003cbr\u003eFor example, there are 3 cards, whose strings are S1\u003d\"ab\", S2\u003d\"bcc\", S3\u003d\"ccb\". There are 6 possible sticking:\u003cbr\u003e1.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S2, S2-\u0026gt;S3, S3-\u0026gt;S1, the score is 1+3+0 \u003d 4\u003cbr\u003e2.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S2, S2-\u0026gt;S1, S3-\u0026gt;S3, the score is 1+0+0 \u003d 1\u003cbr\u003e3.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S3, S3-\u0026gt;S1, S2-\u0026gt;S2, the score is 0+0+0 \u003d 0\u003cbr\u003e4.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S3, S3-\u0026gt;S2, S2-\u0026gt;S1, the score is 0+3+0 \u003d 3\u003cbr\u003e5.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S1, S2-\u0026gt;S2, S3-\u0026gt;S3, the score is 0+0+0 \u003d 0\u003cbr\u003e6.\u0026nbsp;\u0026nbsp;S1-\u0026gt;S1, S2-\u0026gt;S3, S3-\u0026gt;S2, the score is 0+3+3 \u003d 6 \u003cbr\u003eSo the best score is 6.\u003cbr\u003e\u003cbr\u003eGiven the information of all the cards, please help Jimmy find the best possible score.\u003cbr\u003e\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are several test cases. The first line of each test case contains an integer N (1 \u0026lt;\u003d N \u0026lt;\u003d 200). Each of the next N lines contains a string Si. You can assume the strings contain alphabets (\u0027a\u0027-\u0027z\u0027, \u0027A\u0027-\u0027Z\u0027) only, and the length of every string is no more than 1000. \u003cbr\u003e\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output one line for each test case, indicating the corresponding answer."}},{"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\nab\r\nbcc\r\nccb\r\n1\r\nabcd\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}