#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
template <typename T>
void write(T a) {
  if (a < 0) {
    putchar('-');
    write(-a);
    return;
  }
  if (a < 10) {
    putchar('0' + a);
    return;
  }
  write(a / 10);
  putchar((char)('0' + (a % 10)));
}
void read(int& x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-' ? -f : f, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
void docfile() {
  if (ifstream("FORM.inp")) {
    freopen("FORM.inp", "r", stdin);
    freopen("FORM.out", "w", stdout);
  } else if (ifstream("LMINMAX"
                      ".inp")) {
    freopen(
        "LMINMAX"
        ".inp",
        "r", stdin);
    freopen(
        "LMINMAX"
        ".out",
        "w", stdout);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, t, j;
  string s;
  cin >> n;
  while (n--) {
    j = -1;
    cin >> t >> s;
    if (t < 11) {
      cout << "NO" << endl;
    } else {
      for (int i = 0; i < s.length(); i++) {
        if (s[i] == '8') {
          j = i;
          break;
        }
      }
      if (j == -1 || j > t - 11)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
}
