#include <bits/stdc++.h>
using namespace std;
int n, t;
char a[111];
int main() {
  cin >> t;
  while (t--) {
    int d8 = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      if (a[i] == '8') d8++;
    }
    int m = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] == '8') {
        m = i;
        break;
      }
    }
    if (n < 11 || d8 == 0)
      cout << "NO"
           << "\n";
    else if (n - m >= 10)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
}
