#include <bits/stdc++.h>
using namespace std;
int x, l, i, j, poz_gas, ok;
char s[105];
int main() {
  cin >> x;
  for (l = 1; l <= x; l++) {
    cin >> i;
    cin.get();
    cin.get(s, 105);
    for (j = 0; j < i; j++) {
      if (strchr("8", s[j]) && ok == 0) {
        poz_gas = j;
        ok = 1;
      }
    }
    if (i - poz_gas >= 11 && ok == 1)
      cout << "YES\n";
    else
      cout << "NO\n";
    poz_gas = 0;
    ok = 0;
    cin.get();
  }
  return 0;
}
