#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string str;
    cin >> str;
    int flag = 0;
    if (n < 11)
      cout << "NO\n";
    else {
      long long i;
      for (i = 0; i <= n - 9; i++) {
        if (str[i] == '8') {
          flag = 1;
          break;
        }
      }
      long long count = 0;
      if (flag == 1) {
        for (; i < n; i++) {
          if (str[i] >= '0' && str[i] <= '9') count++;
        }
      }
      if (flag == 0 || count < 11)
        cout << "NO\n";
      else
        cout << "YES\n";
    }
  }
}
