{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eLittle Lovro likes to play games with words. During the last few weeks he realized that some words don\u0027t like each other.\u003c/p\u003e\r\n\u003cp\u003eThe words A and B \u003cstrong\u003edon\u0027t like\u003c/strong\u003e each other if \u003cstrong\u003ethe word A is lexicographically before the word B\u003c/strong\u003e, but \u003cstrong\u003ethe word B\u0027 is lexicographically before the word A\u0027\u003c/strong\u003e, where X\u0027 stands for the word X reversed (if X \u003d “kamen”, then X\u0027 \u003d “nemak”). For example, the words “lova” and “novac” like each other, but the words “aron” and “sunce” don\u0027t like each other.\u003c/p\u003e\r\n\u003cp\u003eGiven some set of the words, we define \u003cstrong\u003ethe degree of chaos\u003c/strong\u003e of the set as \u003cstrong\u003ethe number of pairs\u003c/strong\u003e of different words that \u003cstrong\u003edon\u0027t\u003c/strong\u003e like each other.\u003c/p\u003e\r\n\u003cp\u003eWrite a program that, given a set of words, finds the chaos degree for the set.\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of input contains an integer \u003cem\u003eN\u003c/em\u003e, 2 ≤ \u003cem\u003eN\u003c/em\u003e ≤ 100 000.\u003c/p\u003e\r\n\u003cp\u003eEach of the following \u003cem\u003eN\u003c/em\u003e lines contains one word – a sequence of at most 10 lowercase letters of the English alphabet (\u0027a\u0027 – \u0027z\u0027). There will be no two identical words in the set.\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eThe first and only line of output should contain a single integer – the chaos degree of the given set of words.\u003c/p\u003e\r\n\u003cp\u003eNote: use 64-bit signed integer type (int64 in Pascal, long long in C/C++)\u003c/p\u003e\r\n\u003ch3\u003eExamples\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\r\nlopta\r\nkugla\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\nlova\r\nnovac\r\naron\r\nsunce \r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e14\r\nbranimir\r\nvladimir\r\ntom\r\nkruz \r\nbred \r\npit\r\nzemlja\r\nnije\r\nravna\r\nploca\r\nko\r\nje\r\nzapalio \r\nzito\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e48\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\n\u003c/div\u003e"}}]}