importjava.util.*;publicclassSolution{staticintlastIndex;staticHashMap<String,Integer>map=newHashMap<>();staticString[]keys={"0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"};staticint[]values={0,1,2,3,4,5,6,7,8,9};publicstaticvoidmain(String[]args){for(inti=0;i<keys.length;i++){// map에 암호문과 해당 번호 세팅map.put(keys[i],values[i]);}Scannersc=newScanner(System.in);intT=sc.nextInt();for(inttc=1;tc<=T;tc++){inteven=0;intodd=0;intres=0;booleancheck=true;intcols=sc.nextInt();introws=sc.nextInt();for(inti=0;i<cols;i++){Stringrow=sc.next();if(row.contains("1")&&check){lastIndex=row.lastIndexOf("1");Stringsentence=row.substring(lastIndex-55,lastIndex+1);int[]code=newint[8];for(intj=0;j<8;j++){Stringtemp=sentence.substring(j*7,j*7+7);if(map.containsKey(temp)){// 암호문을 가지고 있다면code[j]=map.get(temp);}}odd=0;even=0;res=0;for(intk=0;k<code.length;k=k+2){odd+=code[k];}odd=odd*3;for(intk=1;k<code.length;k=k+2){even+=code[k];}if(((odd+even)%10)==0){for(intk=0;k<code.length;k++){res+=code[k];}}System.out.println("#"+tc+" "+res);check=false;}else{row=null;}}}}}