{"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\"\u003e$N$来自不同国家的青蛙站成一排。每个国家用一个小写字母表示。相邻青蛙之间的距离(例如$1^{st}$和$2^{nd}$青蛙,$N - 1^{th}$和$N^{th}$青蛙等)恰好为$1$。如果两只青蛙来自同一个国家,则它们是朋友。\u003cbr\u003e\u003cbr\u003e最亲密的朋友是距离最\u003cb\u003e短\u003c/b\u003e的一对朋友。帮助我们找到这个距离。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"第一行包含一个整数$T$,表示测试用例的数量。\u003cbr\u003e\u003cbr\u003e每个测试用例只包含长度为$N$的字符串,字符串的第$i^{th}$个字符表示$i^{th}$青蛙的国家。\u003cbr\u003e\u003cbr\u003e$\\cdot$ $1 \\leq T \\leq 50$。\u003cbr\u003e\u003cbr\u003e对于80%的数据,$1 \\leq N \\leq 100$。\u003cbr\u003e\u003cbr\u003e对于100%的数据,$1 \\leq N \\leq 1000$。\u003cbr\u003e\u003cbr\u003e保证字符串只包含小写字母。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,你应该输出“\u003cb\u003eCase #x: y\u003c/b\u003e”,其中$x$表示案例编号,从$1$开始计数,$y$是结果。如果没有来自同一个国家的青蛙,则输出$-1$。"}},{"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\r\nabcecba\r\nabc\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 2\r\nCase #2: -1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}