{"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$\\cdot$ 80% のデータに対して $1 \\leq N \\leq 100$。\u003cbr\u003e\u003cbr\u003e$\\cdot$ 100% のデータに対して $1 \\leq N \\leq 1000$。\u003cbr\u003e\u003cbr\u003e$\\cdot$ 文字列には小文字のみが含まれます。"}},{"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"}}]}