{"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\"\u003eYou may already know that how the World Finals slots are distributed in EC sub-region. But you still need to keep reading the problem in case some rules are different.\u003cbr\u003eThere are totally G slots for EC sub-region. X slots will be distributed among five China regional sites and Y slots will be distributed to the EC-Final. Of course X and Y are non-negative integers and X + Y \u003d G.\u003cbr\u003eHere is how the X slots be distributed:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003e 1. Slots are assigned to the Asia Regional sites from the first place, the second place, · · · , last place.\u003cbr\u003e 2. For schools having the same place across the sites, the slots will be given in the order of the number of “effective \u003cbr\u003e teams” in the sites.\u003cbr\u003e 3. No school could be assigned a slot 2 times, which means the schools will be skipped if they already got a slot.\u003cbr\u003e\u003c/pre\u003e\u003cbr\u003eAfter X slots are distributed, the EC-Final ranklist from highest rank will be assigned Y slots for those schools that haven’t got a slot yet.\u003cbr\u003eNow here comes a sad story, as X and Y are not announced until the end of the last regional contest of that year, even later!!!\u003cbr\u003eTeachers from a school are worried about the whether they can advance to WF whatever the X and Y is. Let’s help them find out the results before the announcement of X and Y .\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input gives the number of test cases, T. T test cases follow.\u003cbr\u003eEach test case starts with a line consisting of 1 integer and 1 string, G representing the sum of X and Y and S representing the name of the worried school.\u003cbr\u003eNext 5 lines each consists of 20 string representing the names of top 20 schools in each site. The sites are given in the order of the number of “effective teams” which means the first site has the largest number of “effective teams” and the last site has the smallest numebr of “effective teams”.\u003cbr\u003eThe last line consists of 20 strings representing the names of top 20 schools in EC-Final site. No school can appear more than once in each ranklist"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is “ADVANCED!” if every non-negative value X, Y will advance the school. Otherwise, output the smallest value of Y that makes the school sad.\u003cbr\u003e$\\bullet$ 1 ≤ T ≤ 200.\u003cbr\u003e$\\bullet$ School names only consist of upper case characters ‘A’ - ‘Z’ and the length is at most 5.\u003cbr\u003e$\\bullet$ 1 ≤ G ≤ 20.\u003cbr\u003e"}},{"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\n10 IJU\r\nUIV GEV LJTV UKV QLV TZTV AKOV TKUV\r\nGAV DVIL TDBV ILVTU AKV VTUD IJU IEV\r\nHVDBT YKUV ATUV TDOV\r\nTKUV UIV GEV AKV AKOV GAV DOV TZTV\r\nAVDD IEV LJTV CVQU HVDBT AKVU XIV TDVU\r\nOVEU OVBB KMV OFV\r\nQLV OCV TDVU COV EMVU TEV XIV\r\nVFTUD OVBB OFV DVHC ISCTU VTUD OVEU DTV\r\nHEVU TEOV TDV TDBV CKVU\r\nCVBB IJU QLV LDDLQ TZTV GEV GAV KMV\r\nOFV AVGF TXVTU VFTUD IEV OVEU OKV DVIL\r\nTEV XIV TDVU TKUV\r\nUIV DVIL VFTUD GEV ATUV AKV TZTV QLV\r\nTIV OVEU TKUV UKV IEV OKV CVQU COV\r\nOFOV CVBB TDVU IOV\r\nUIV TKUV CVBB AKV TZTV VFTUD UKV GEV\r\nQLV OVEU OVQU AKOV TDBV ATUV LDDLQ AKVU\r\nGAV SVD TDVU UPOHK\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eFor the first test case, the optimal solution is X \u003d 6 and Y \u003d 4, at this time the advanced schools were [UIV, TKUV, QLV, CVBB, GEV, OCV, AKV, TZTV, VFTUD, UKV].\u003cbr\u003e"}}]}