#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    cin >> n;
    char s[1000];
    cin >> s;
    if (n < 11) {
      printf("NO\n");
      continue;
    }
    for (i = 0; i < n; i++) {
      if (s[i] == '8') break;
    }
    if (n - i >= 11) {
      printf("YES\n");
      continue;
    }
    printf("NO\n");
  }
}
