{"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\"\u003eLadies and gentlemen, please sit up straight.\u003cbr\u003e \u003cb\u003eDon\u0027t tilt your head\u003c/b\u003e. I\u0027m serious.\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/32d5d30dac2c4def0e1d21b11ec95d22?v\u003d1713628607\"\u003e\u003c/center\u003e\u003cbr\u003eFor $n$ given strings $S_1,S_2,\\cdots,S_n$, labelled from $1$ to $n$, you should find the largest $i~(1\\le i\\le n)$ such that there exists an integer $j~(1\\le j\u0026lt;i)$ and $S_j$ is not a substring of $S_i$.\u003cbr\u003e\u003cbr\u003eA substring of a string $S_i$ is another string that occurs \u003cb\u003ein\u003c/b\u003e $S_i$. For example, ``ruiz\" is a substring of ``ruizhang\", and ``rzhang\" is not a substring of ``ruizhang\".\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer $t~(1\\le t\\le 50)$ which is the number of test cases.\u003cbr\u003eFor each test case, the first line is the positive integer $n~(1\\le n\\le 500)$ and in the following $n$ lines list are the strings $S_1,S_2,\\cdots,S_n$.\u003cbr\u003eAll strings are given in lower-case letters and strings are no longer than $2000$ letters."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output the largest label you get. If it does not exist, output $-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\u003e4\r\n5\r\nab\r\nabc\r\nzabc\r\nabcd\r\nzabcd\r\n4\r\nyou\r\nlovinyou\r\naboutlovinyou\r\nallaboutlovinyou\r\n5\r\nde\r\ndef\r\nabcd\r\nabcde\r\nabcdef\r\n3\r\na\r\nba\r\nccc\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 4\r\nCase #2: -1\r\nCase #3: 4\r\nCase #4: 3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}