public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = in.nextInt();
for(int i = 0;i < size;i++){
int num = in.nextInt();
String phone = in.next();
if(num < 11){
System.out.println("NO");
continue;
}else{
for(int j = 0;j < (num-10);j++){
char here = phone.charAt(j);
System.out.println(here);
if(here == '-'){
j++;
here = phone.charAt(j);
}
if(here == '8'){
System.out.println("YES");
continue;
}
if(j == (num-11)){
System.out.println("NO");
break;
}
}
}
}
}