#include <bits/stdc++.h>
using namespace std;
int t, n, c, r, lungime;
char numar[200];
int main() {
  cin >> t;
  for (c = 1; c <= t; c++) {
    cin >> n;
    cin >> numar;
    lungime = n;
    r = 0;
    while ((numar[r] != '8') & (r < n)) r++;
    if (lungime - r >= 11)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
