{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eSonya had a birthday recently. She was presented with the matrix of size $$$n\\times m$$$ and consist of lowercase Latin letters. We assume that the rows are numbered by integers from $$$1$$$ to $$$n$$$ from bottom to top, and the columns are numbered from $$$1$$$ to $$$m$$$ from left to right. \u003c/p\u003e\u003cp\u003eLet\u0027s call a submatrix $$$(i_1, j_1, i_2, j_2)$$$ $$$(1\\leq i_1\\leq i_2\\leq n; 1\\leq j_1\\leq j_2\\leq m)$$$ elements $$$a_{ij}$$$ of this matrix, such that $$$i_1\\leq i\\leq i_2$$$ and $$$j_1\\leq j\\leq j_2$$$. Sonya states that a submatrix is beautiful if we can \u003cspan class\u003d\"tex-font-style-bf\"\u003eindependently\u003c/span\u003e reorder the characters in each \u003cspan class\u003d\"tex-font-style-bf\"\u003erow\u003c/span\u003e (not in column) so that all \u003cspan class\u003d\"tex-font-style-bf\"\u003erows and columns\u003c/span\u003e of this submatrix form palidroms. \u003c/p\u003e\u003cp\u003eLet\u0027s recall that a string is called palindrome if it reads the same from left to right and from right to left. For example, strings $$$abacaba, bcaacb, a$$$ are palindromes while strings $$$abca, acbba, ab$$$ are not.\u003c/p\u003e\u003cp\u003eHelp Sonya to find the number of beautiful submatrixes. Submatrixes are different if there is an element that belongs to only one submatrix.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$m$$$ $$$(1\\leq n, m\\leq 250)$$$\u0026nbsp;— the matrix dimensions.\u003c/p\u003e\u003cp\u003eEach of the next $$$n$$$ lines contains $$$m$$$ lowercase Latin letters.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint one integer\u0026nbsp;— the number of beautiful submatrixes.\u003c/p\u003e"}},{"title":"Examples","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\u003e1 3\naba\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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 3\naca\naac\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e11\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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 5\naccac\naaaba\ncccaa\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e43\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, the following submatrixes are beautiful: $$$((1, 1), (1, 1)); ((1, 2), (1, 2));$$$ $$$((1, 3), (1, 3)); ((1, 1), (1, 3))$$$.\u003c/p\u003e\u003cp\u003eIn the second example, all submatrixes that consist of one element and the following are beautiful: $$$((1, 1), (2, 1));$$$ $$$((1, 1), (1, 3)); ((2, 1), (2, 3)); ((1, 1), (2, 3)); ((2, 1), (2, 2))$$$.\u003c/p\u003e\u003cp\u003eSome of the beautiful submatrixes are: $$$((1, 1), (1, 5)); ((1, 2), (3, 4));$$$ $$$((1, 1), (3, 5))$$$.\u003c/p\u003e\u003cp\u003eThe submatrix $$$((1, 1), (3, 5))$$$ is beautiful since it can be reordered as:\u003c/p\u003e\u003cpre class\u003d\"verbatim\"\u003e\u003cbr\u003eaccca\u003cbr\u003eaabaa\u003cbr\u003eaccca\u003cbr\u003e\u003c/pre\u003e\u003cp\u003eIn such a matrix every row and every column form palindromes.\u003c/p\u003e"}}]}