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