{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"The twenty-first century is a biology-technology developing century. One of the most attractive and challenging tasks is on the gene project, especially on gene sorting program. Recently we know that a gene is made of DNA. The nucleotide bases from which DNA is built are A(adenine), C(cytosine), G(guanine), and T(thymine). Given several segments of a gene, you are asked to make a shortest sequence from them. The sequence should use all the segments, and you cannot flip any of the segments.\r\u003cbr\u003e\r\u003cbr\u003eFor example, given \u0027TCGG\u0027, \u0027GCAG\u0027, \u0027CCGC\u0027, \u0027GATC\u0027 and \u0027ATCG\u0027, you can slide the segments in the following way and get a sequence of length 11. It is the shortest sequence (but may be not the only one).\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/515635987263ea3f4117d9e04ef4ecc1?v\u003d1726100120\"\u003e\u003c/center\u003e\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line is an integer T (1 \u0026lt;\u003d T \u0026lt;\u003d 20), which shows the number of the cases. Then T test cases follow. The first line of every test case contains an integer N (1 \u0026lt;\u003d N \u0026lt;\u003d 10), which represents the number of segments. The following N lines express N segments, respectively. Assuming that the length of any segment is between 1 and 20."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a line containing the length of the shortest sequence that can be made from these segments."}},{"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\u003e1\r\n5\r\nTCGG\r\nGCAG\r\nCCGC\r\nGATC\r\nATCG\r\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"}}]}