importjava.io.IOException; importjava.io.FileInputStream; importjava.io.InputStreamReader; importjava.io.BufferedReader; importjava.io.PrintWriter; importjava.io.OutputStreamWriter; importjava.io.StreamTokenizer; publicclassMain{ publicstaticbooleanDEBUG=false; publicBufferedReadercin; publicPrintWritercout; publicStreamTokenizertokenizer; publicintn, m, k; publiclongtotal; publiclong[] mArr, nArr, kArr; publicvoidinit() { try { if (DEBUG) { cin=newBufferedReader(newInputStreamReader( newFileInputStream("d:\\OJ\\uva_in.txt"))); } else { cin=newBufferedReader(newInputStreamReader(System.in)); } } catch (IOExceptione) { e.printStackTrace(); } cout=newPrintWriter(newOutputStreamWriter(System.out)); tokenizer=newStreamTokenizer(cin); } publicStringnext() { try { tokenizer.nextToken(); if (tokenizer.ttype==StreamTokenizer.TT_EOF) returnnull; elseif (tokenizer.ttype==StreamTokenizer.TT_WORD) returntokenizer.sval; elseif (tokenizer.ttype==StreamTokenizer.TT_NUMBER) returnString.valueOf((int)tokenizer.nval); } catch (IOExceptione) { e.printStackTrace(); } returnnull; } publicvoidinput() { try { n=Integer.parseInt(next()); m=Integer.parseInt(next()); k=Integer.parseInt(next()); total=0; mArr=newlong[m]; kArr=newlong[k]; nArr=newlong[n-m-k]; for (inti=0; i<m; i++) { mArr[i] =Long.parseLong(next()); total+=mArr[i]; } for (inti=0; i<k; i++) { kArr[i] =Long.parseLong(next()); total+=kArr[i]; } inttmpn=n-m-k; for (inti=0; i<tmpn; i++) { nArr[i] =Long.parseLong(next()); total+=nArr[i]; } } catch (Exceptione) { e.printStackTrace(); } } publicvoidsolve(intt) { cout.printf("Case #%d: ", t); intans1=0, ans2=0; for (inti=0; i<m; i++) { longtmp1=n*mArr[i] -total; longtmp2=n*mArr[ans1] -total; if (Math.abs(tmp1) <Math.abs(tmp2)) ans1=i; elseif (Math.abs(tmp1) ==Math.abs(tmp2) &&mArr[i] <mArr[ans1]) ans1=i; } for (inti=0; i<k; i++) { longtmp1=n*kArr[i] -total; longtmp2=n*kArr[ans2] -total; if (Math.abs(tmp1) <Math.abs(tmp2)) ans2=i; elseif (Math.abs(tmp1) ==Math.abs(tmp2) &&kArr[i] <kArr[ans2]) ans2=i; } cout.printf("%d %d", mArr[ans1], kArr[ans2]); cout.println(); cout.flush(); } publicstaticvoidmain(String[] args) { try { Mainsolver=newMain(); solver.init(); intt=Integer.parseInt(solver.next()); for (inti=1; i<=t; i++) { solver.input(); solver.solve(i); } } catch (Exceptione) { e.printStackTrace(); } } }