{"raw_statement":[{"iden":"problem statement","content":"You are given $N$ strings $S_1, S_2, \\ldots, S_N$.\nFind the minimum length of a string that contains all these strings as substrings.\nHere, a string $S$ contains a string $T$ as a substring if $T$ can be obtained by deleting zero or more characters from the beginning and zero or more characters from the end of $S$."},{"iden":"constraints","content":"*   $N$ is an integer.\n*   $1 \\leq N \\leq 20$\n*   $S_i$ is a string consisting of lowercase English letters whose length is at least $1$.\n*   The total length of $S_1, S_2, \\dots, S_N$ is at most $2\\times 10^5$."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$"},{"iden":"sample input 1","content":"3\nsnuke\nkensho\nuk"},{"iden":"sample output 1","content":"9\n\nThe string `snukensho` of length $9$ contains all of $S_1$, $S_2$, and $S_3$ as substrings.\nSpecifically, the first to fifth characters of `snukensho` correspond to $S_1$, the fourth to ninth correspond to $S_2$, and the third to fourth correspond to $S_3$.\nNo shorter string contains all of $S_1$, $S_2$, and $S_3$ as substrings. Thus, the answer is $9$."},{"iden":"sample input 2","content":"3\nabc\nabc\narc"},{"iden":"sample output 2","content":"6"},{"iden":"sample input 3","content":"6\ncmcmrcc\nrmrrrmr\nmrccm\nmmcr\nrmmrmrcc\nccmcrcmcm"},{"iden":"sample output 3","content":"27"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}