#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, f = 0;
    scanf("%d", &n);
    char a[n + 1];
    scanf("%s", a);
    n -= 11;
    for (int i = 0; i <= n; i++) {
      if (a[i] == '8') {
        f = 1;
        break;
      }
    }
    if (f == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
