{"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\"\u003eBiologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represented as a string containing characters \u0027A\u0027, \u0027G\u0027 , \u0027C\u0027 and \u0027T\u0027. The repairing techniques are simply to change some characters to eliminate all segments causing diseases. For example, we can repair a DNA \"AAGCAG\" to \"AGGCAC\" to eliminate the initial causing disease segments \"AAG\", \"AGC\" and \"CAG\" by changing two characters. Note that the repaired DNA can still contain only characters \u0027A\u0027, \u0027G\u0027, \u0027C\u0027 and \u0027T\u0027.\u003cbr\u003e\u003cbr\u003eYou are to help the biologists to repair a DNA by changing least number of characters.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of multiple test cases. Each test case starts with a line containing one integers N (1 ≤ N ≤ 50), which is the number of DNA segments causing inherited diseases.\u003cbr\u003eThe following N lines gives N non-empty strings of length not greater than 20 containing only characters in \"AGCT\", which are the DNA segments causing inherited disease.\u003cbr\u003eThe last line of the test case is a non-empty string of length not greater than 1000 containing only characters in \"AGCT\", which is the DNA to be repaired.\u003cbr\u003e\u003cbr\u003eThe last test case is followed by a line containing one zeros."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a line containing the test case number( beginning with 1) followed by the\u003cbr\u003enumber of characters which need to be changed. If it\u0027s impossible to repair the given DNA, print -1."}},{"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\u003e2\r\nAAA\r\nAAG\r\nAAAG \r\n2\r\nA\r\nTG\r\nTGAATG\r\n4\r\nA\r\nG\r\nC\r\nT\r\nAGT\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 1\r\nCase 2: 4\r\nCase 3: -1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}